Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

7/11 master -> stable #90

Merged
merged 32 commits into from
Jul 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e6bfcd2
start on simplifying event handling
dfreedm Jun 18, 2013
55ce6e1
clean up mouse module to be simply on document
dfreedm Jun 18, 2013
ecc79d0
test: update karma config
Jun 20, 2013
ef83854
touch events can come through shadow, speeding up target finding
dfreedm Jun 20, 2013
bec9bcb
fix binding for register, move scrolltypes about
dfreedm Jun 20, 2013
614e60b
Touch will try to use touch-action or use the old MutationObserver me…
dfreedm Jun 20, 2013
731b394
turn on new touch system
dfreedm Jun 20, 2013
977b58e
Merge pull request #78 from azakus/more-modules
dfreedm Jun 24, 2013
0328e5d
fix tests
dfreedm Jun 24, 2013
ad7371d
Merge pull request #80 from azakus/master
dfreedm Jun 24, 2013
9d1453a
Use Shadow.olderShadowRoot when possible
dfreedm Jun 24, 2013
3c1eb52
Merge pull request #82 from azakus/master
dfreedm Jun 24, 2013
1a051bb
Add a concat step to build to provide an unminified version for devel…
kborchers Jun 25, 2013
0db65d8
Merge pull request #84 from kborchers/concat-master
dfreedm Jun 25, 2013
4f83863
ignore concat version of build
dfreedm Jun 25, 2013
db961d2
fix all my mistakes with touch handlers
dfreedm Jun 26, 2013
87199e3
Merge pull request #85 from azakus/master
dfreedm Jun 26, 2013
9d47dd1
Set versions for grunt and grunt-contrib plugins to avoid issues from…
kborchers Jun 27, 2013
0d93078
Merge pull request #86 from kborchers/versions
dfreedm Jun 27, 2013
075582d
a little more flexible versions, still < grunt 0.5
dfreedm Jun 27, 2013
a38f1ab
Don't override native (or otherwise) PointerEvent
dfreedm Jun 28, 2013
0fbec53
handle IE 11 use of string pointerType
dfreedm Jun 29, 2013
812f79e
find all the shadows of an element
dfreedm Jun 29, 2013
97d0b2b
Fix simple reference error in !IE
dfreedm Jul 1, 2013
84ac51c
Map API has a forEach, use ES6 Map where available
dfreedm Jul 1, 2013
b695c6c
Refactor touch
dfreedm Jul 1, 2013
7abdea1
Fix some silly errors, tests for PointerMap.forEach, remove setTouchA…
dfreedm Jul 1, 2013
675263f
test third arg to forEach callback
dfreedm Jul 2, 2013
72816cf
remove extraneous `shadow` call
dfreedm Jul 2, 2013
40cd985
disable efp optimization if touch moves between shadowroots
dfreedm Jul 2, 2013
0d1a45d
Merge pull request #88 from azakus/event-cleanup
dfreedm Jul 2, 2013
ea792e1
experiment with new polymer build setup
dfreedm Jul 3, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build/
node_modules
pointerevents.min.js
pointerevents.min.js.map
pointerevents.dev.js
32 changes: 16 additions & 16 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-yuidoc');
grunt.loadNpmTasks('grunt-karma-0.9.1');
grunt.loadNpmTasks('grunt-karma');

var os = require('os').type();
var browsers = ['Chrome', 'Firefox'];
var sourceFiles = grunt.file.readJSON('build.json');

if (os == 'Darwin') {
browsers.push('ChromeCanary');
}
Expand All @@ -13,27 +16,24 @@ module.exports = function(grunt) {
}

grunt.initConfig({
concat: {
pointerevents: {
options: {
stripBanners: true,
banner: grunt.file.read('LICENSE')
},
src: sourceFiles,
dest: 'pointerevents.dev.js'
}
},
uglify: {
pointerevents: {
options: {
sourceMap: 'pointerevents.min.js.map',
banner: grunt.file.read('LICENSE')
},
dest: 'pointerevents.min.js',
src: [
'src/boot.js',
'src/touch-action.js',
'src/PointerEvent.js',
'src/pointermap.js',
'src/sidetable.js',
'src/dispatcher.js',
'src/installer.js',
'src/mouse.js',
'src/touch.js',
'src/ms.js',
'src/platform-events.js',
'src/capture.js',
]
src: sourceFiles
}
},
karma: {
Expand All @@ -53,7 +53,7 @@ module.exports = function(grunt) {
}
});

grunt.registerTask('default', 'uglify');
grunt.registerTask('default', ['concat', 'uglify']);
grunt.registerTask('test', 'karma:polymer');
grunt.registerTask('test-buildbot', 'karma:buildbot');
};
14 changes: 14 additions & 0 deletions build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
"src/boot.js",
"src/touch-action.js",
"src/PointerEvent.js",
"src/pointermap.js",
"src/sidetable.js",
"src/dispatcher.js",
"src/installer.js",
"src/mouse.js",
"src/touch.js",
"src/ms.js",
"src/platform-events.js",
"src/capture.js"
]
160 changes: 82 additions & 78 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,82 @@
// Karma configuration

// base path, that will be used to resolve files and exclude
basePath = '';

// list of files / patterns to load in the browser
files = [
'node_modules/chai/chai.js',
'node_modules/chai-spies/chai-spies.js',
'src/boot.js',
'src/PointerEvent.js',
'src/pointermap.js',
'src/sidetable.js',
'src/dispatcher.js',
'src/installer.js',
'src/mouse.js',
'src/touch.js',
'src/ms.js',
'src/platform-events.js',
'src/capture.js',
'tests/setup.js',
'tests/karma-setup.js',
'tests/!(setup|karma-setup).js'
];

// list of files to exclude
exclude = [];

frameworks = ['mocha'];

// test results reporter to use
// possible values: 'dots', 'progress', 'junit'
reporters = ['progress'];

// web server port
port = 9876;

// cli runner port
runnerPort = 9100;

// enable / disable colors in the output (reporters and logs)
colors = true;

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
autoWatch = false;

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers = ['ChromeCanary'];

// If browser does not capture in given timeout [ms], kill it
captureTimeout = 50000;

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = true;

reportSlowThan = 500;

preprocessors = {};

plugins = [
'karma-mocha',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-script-launcher',
'karma-crbot-reporter'
];
module.exports = function(karma) {
karma.configure({
// Karma configuration

// base path, that will be used to resolve files and exclude
basePath: '',

// list of files / patterns to load in the browser
files: [
'node_modules/chai/chai.js',
'node_modules/chai-spies/chai-spies.js',
'src/boot.js',
'src/PointerEvent.js',
'src/pointermap.js',
'src/sidetable.js',
'src/dispatcher.js',
'src/installer.js',
'src/mouse.js',
'src/touch.js',
'src/ms.js',
'src/platform-events.js',
'src/capture.js',
'tests/setup.js',
'tests/karma-setup.js',
'tests/!(setup|karma-setup).js'
],

// list of files to exclude
exclude: [],

frameworks: ['mocha'],

// test results reporter to use
// possible values: 'dots', 'progress', 'junit'
reporters: ['progress'],

// web server port
port: 9876,

// cli runner port
runnerPort: 9100,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: karma.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['ChromeCanary'],

// If browser does not capture in given timeout [ms], kill it
captureTimeout: 50000,

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: true,

reportSlowThan: 500,

preprocessors: {},

plugins: [
'karma-mocha',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-script-launcher',
'karma-crbot-reporter'
]
});
};
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
"mocha": "*",
"chai": "*",
"chai-spies": "*",
"grunt": "*",
"grunt-contrib-uglify": "*",
"grunt-contrib-yuidoc": "*",
"grunt": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-yuidoc": "~0.4.0",
"karma-mocha": "*",
"karma-script-launcher": "*",
"karma-crbot-reporter": "*",
"grunt-karma-0.9.1": "~0.4.3"
"grunt-karma": "~0.5.0"
},
"scripts": {
"test": "grunt test"
Expand Down
4 changes: 2 additions & 2 deletions samples/scroller/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
scroller.setAttribute('touch-action', 'pan-y');
}
function scroll() {
scroller.setAttribute('touch-action', 'scroll');
scroller.setAttribute('touch-action', 'auto');
}
function none() {
scroller.setAttribute('touch-action', 'none');
Expand All @@ -62,7 +62,7 @@
'pointercancel'
].forEach(function(e) {
document.addEventListener(e, function(e) {
console.log(e.type, e.clientX, e.clientY);
console.log(e.type, e.target, e.clientX, e.clientY);
});
});
</script>
Expand Down
1 change: 0 additions & 1 deletion samples/shadow/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
s.appendChild(pd);
// Register shadow dom touch-action
PointerEventsPolyfill.register(s);
PointerEventsPolyfill.setTouchAction(s, host.getAttribute('touch-action'));
// event listeners
host.addEventListener('pointerdown', function(e){ console.log(e.target) });
d.addEventListener('pointerdown', function(e){ console.log(e.target) });
Expand Down
4 changes: 3 additions & 1 deletion src/PointerEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,7 @@
}

// attach to window
scope.PointerEvent = PointerEvent;
if (!scope.PointerEvent) {
scope.PointerEvent = PointerEvent;
}
})(window);
40 changes: 35 additions & 5 deletions src/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,33 @@
return inEl.shadowRoot || inEl.webkitShadowRoot;
}
},
canTarget: function(scope) {
return scope && Boolean(scope.elementFromPoint);
canTarget: function(shadow) {
return shadow && Boolean(shadow.elementFromPoint);
},
targetingShadow: function(inEl) {
var s = this.shadow(inEl);
if (this.canTarget(s)) {
return s;
}
},
olderShadow: function(shadow) {
var os = shadow.olderShadowRoot;
if (!os) {
var se = shadow.querySelector('shadow');
if (se) {
os = se.olderShadowRoot;
}
}
return os;
},
allShadows: function(element) {
var shadows = [], s = this.shadow(element);
while(s) {
shadows.push(s);
s = this.olderShadow(s);
}
return shadows;
},
searchRoot: function(inRoot, x, y) {
if (inRoot) {
var t = inRoot.elementFromPoint(x, y);
Expand All @@ -32,9 +50,7 @@
st = sr.elementFromPoint(x, y);
if (!st) {
// check for older shadows
os = sr.querySelector('shadow');
// check the older shadow if available
sr = os && os.olderShadowRoot;
sr = this.olderShadow(sr);
} else {
// shadowed element may contain a shadow root
var ssr = this.targetingShadow(st);
Expand All @@ -45,8 +61,22 @@
return t;
}
},
owner: function(element) {
var s = element;
// walk up until you hit the shadow root or document
while (s.parentNode) {
s = s.parentNode;
}
return s;
},
findTarget: function(inEvent) {
var x = inEvent.clientX, y = inEvent.clientY;
// if the listener is in the shadow root, it is much faster to start there
var s = this.owner(inEvent.target);
// if x, y is not in this root, fall back to document search
if (!s.elementFromPoint(x, y)) {
s = document;
}
return this.searchRoot(document, x, y);
}
};
Expand Down
Loading