polymer-paper-elements-rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +51 -0
- data/Rakefile +1 -0
- data/app/assets/components/iron-a11y-announcer/iron-a11y-announcer.html +125 -0
- data/app/assets/components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html +418 -0
- data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
- data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
- data/app/assets/components/iron-behaviors/iron-button-state.html +195 -0
- data/app/assets/components/iron-behaviors/iron-control-state.html +102 -0
- data/app/assets/components/iron-fit-behavior/iron-fit-behavior.html +230 -0
- data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
- data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
- data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
- data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
- data/app/assets/components/iron-icon/hero.svg +19 -0
- data/app/assets/components/iron-icon/iron-icon.html +187 -0
- data/app/assets/components/iron-icons/av-icons.html +73 -0
- data/app/assets/components/iron-icons/communication-icons.html +59 -0
- data/app/assets/components/iron-icons/device-icons.html +94 -0
- data/app/assets/components/iron-icons/editor-icons.html +70 -0
- data/app/assets/components/iron-icons/hardware-icons.html +61 -0
- data/app/assets/components/iron-icons/hero.svg +35 -0
- data/app/assets/components/iron-icons/image-icons.html +164 -0
- data/app/assets/components/iron-icons/iron-icons.html +303 -0
- data/app/assets/components/iron-icons/maps-icons.html +71 -0
- data/app/assets/components/iron-icons/notification-icons.html +62 -0
- data/app/assets/components/iron-icons/social-icons.html +40 -0
- data/app/assets/components/iron-iconset-svg/iron-iconset-svg.html +191 -0
- data/app/assets/components/iron-input/hero.svg +19 -0
- data/app/assets/components/iron-input/iron-input.html +235 -0
- data/app/assets/components/iron-media-query/hero.svg +29 -0
- data/app/assets/components/iron-media-query/iron-media-query.html +84 -0
- data/app/assets/components/iron-menu-behavior/iron-menu-behavior.html +214 -0
- data/app/assets/components/iron-menu-behavior/iron-menubar-behavior.html +65 -0
- data/app/assets/components/iron-meta/hero.svg +33 -0
- data/app/assets/components/iron-meta/iron-meta.html +352 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-backdrop.html +132 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-behavior.html +432 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-manager.html +107 -0
- data/app/assets/components/iron-range-behavior/iron-range-behavior.html +101 -0
- data/app/assets/components/iron-resizable-behavior/iron-resizable-behavior.html +139 -0
- data/app/assets/components/iron-selector/iron-multi-selectable.html +120 -0
- data/app/assets/components/iron-selector/iron-selectable.html +307 -0
- data/app/assets/components/iron-selector/iron-selection.html +115 -0
- data/app/assets/components/iron-selector/iron-selector.html +71 -0
- data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +100 -0
- data/app/assets/components/neon-animation/animations/cascaded-animation.html +84 -0
- data/app/assets/components/neon-animation/animations/fade-in-animation.html +49 -0
- data/app/assets/components/neon-animation/animations/fade-out-animation.html +49 -0
- data/app/assets/components/neon-animation/animations/hero-animation.html +83 -0
- data/app/assets/components/neon-animation/animations/opaque-animation.html +46 -0
- data/app/assets/components/neon-animation/animations/ripple-animation.html +92 -0
- data/app/assets/components/neon-animation/animations/scale-down-animation.html +65 -0
- data/app/assets/components/neon-animation/animations/scale-up-animation.html +58 -0
- data/app/assets/components/neon-animation/animations/slide-down-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-from-left-animation.html +60 -0
- data/app/assets/components/neon-animation/animations/slide-from-right-animation.html +60 -0
- data/app/assets/components/neon-animation/animations/slide-left-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-right-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-up-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/transform-animation.html +61 -0
- data/app/assets/components/neon-animation/guides/neon-animation.md +313 -0
- data/app/assets/components/neon-animation/neon-animatable-behavior.html +156 -0
- data/app/assets/components/neon-animation/neon-animatable.html +54 -0
- data/app/assets/components/neon-animation/neon-animated-pages.html +208 -0
- data/app/assets/components/neon-animation/neon-animation-behavior.html +88 -0
- data/app/assets/components/neon-animation/neon-animation-runner-behavior.html +110 -0
- data/app/assets/components/neon-animation/neon-animation.html +17 -0
- data/app/assets/components/neon-animation/neon-animations.html +25 -0
- data/app/assets/components/neon-animation/neon-shared-element-animatable-behavior.html +37 -0
- data/app/assets/components/neon-animation/neon-shared-element-animation-behavior.html +66 -0
- data/app/assets/components/neon-animation/web-animations.html +11 -0
- data/app/assets/components/paper-behaviors/paper-button-behavior.html +55 -0
- data/app/assets/components/paper-behaviors/paper-inky-focus-behavior.html +44 -0
- data/app/assets/components/paper-button/paper-button.html +177 -0
- data/app/assets/components/paper-checkbox/metadata.html +17 -0
- data/app/assets/components/paper-checkbox/paper-checkbox.css +149 -0
- data/app/assets/components/paper-checkbox/paper-checkbox.html +163 -0
- data/app/assets/components/paper-dialog-behavior/hero.svg +51 -0
- data/app/assets/components/paper-dialog-behavior/paper-dialog-behavior.html +236 -0
- data/app/assets/components/paper-dialog-behavior/paper-dialog-common.css +58 -0
- data/app/assets/components/paper-dialog-scrollable/hero.svg +69 -0
- data/app/assets/components/paper-dialog-scrollable/paper-dialog-scrollable.html +150 -0
- data/app/assets/components/paper-dialog/hero.svg +58 -0
- data/app/assets/components/paper-dialog/paper-dialog.html +122 -0
- data/app/assets/components/paper-drawer-panel/hero.svg +21 -0
- data/app/assets/components/paper-drawer-panel/paper-drawer-panel.css +142 -0
- data/app/assets/components/paper-drawer-panel/paper-drawer-panel.html +585 -0
- data/app/assets/components/paper-fab/paper-fab.html +159 -0
- data/app/assets/components/paper-header-panel/hero.svg +38 -0
- data/app/assets/components/paper-header-panel/paper-header-panel.html +496 -0
- data/app/assets/components/paper-icon-button/paper-icon-button.html +141 -0
- data/app/assets/components/paper-input/all-imports.html +12 -0
- data/app/assets/components/paper-input/hero.svg +19 -0
- data/app/assets/components/paper-input/paper-input-addon-behavior.html +43 -0
- data/app/assets/components/paper-input/paper-input-behavior.html +293 -0
- data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
- data/app/assets/components/paper-input/paper-input-container.html +495 -0
- data/app/assets/components/paper-input/paper-input-error.html +99 -0
- data/app/assets/components/paper-input/paper-input.html +126 -0
- data/app/assets/components/paper-input/paper-textarea.html +100 -0
- data/app/assets/components/paper-item/all-imports.html +13 -0
- data/app/assets/components/paper-item/paper-icon-item.html +86 -0
- data/app/assets/components/paper-item/paper-item-body.html +93 -0
- data/app/assets/components/paper-item/paper-item-shared.css +19 -0
- data/app/assets/components/paper-item/paper-item.html +95 -0
- data/app/assets/components/paper-material/paper-material.html +98 -0
- data/app/assets/components/paper-menu/hero.svg +35 -0
- data/app/assets/components/paper-menu/paper-menu.html +133 -0
- data/app/assets/components/paper-progress/hero.svg +21 -0
- data/app/assets/components/paper-progress/paper-progress.html +199 -0
- data/app/assets/components/paper-radio-button/hero.svg +22 -0
- data/app/assets/components/paper-radio-button/paper-radio-button.css +109 -0
- data/app/assets/components/paper-radio-button/paper-radio-button.html +148 -0
- data/app/assets/components/paper-radio-group/hero.svg +25 -0
- data/app/assets/components/paper-radio-group/paper-radio-group.html +186 -0
- data/app/assets/components/paper-ripple/hero.svg +30 -0
- data/app/assets/components/paper-ripple/paper-ripple.html +714 -0
- data/app/assets/components/paper-scroll-header-panel/hero.svg +41 -0
- data/app/assets/components/paper-scroll-header-panel/paper-scroll-header-panel.html +455 -0
- data/app/assets/components/paper-slider/hero.svg +20 -0
- data/app/assets/components/paper-slider/paper-slider.css +252 -0
- data/app/assets/components/paper-slider/paper-slider.html +449 -0
- data/app/assets/components/paper-spinner/hero.svg +27 -0
- data/app/assets/components/paper-spinner/paper-spinner.css +325 -0
- data/app/assets/components/paper-spinner/paper-spinner.html +222 -0
- data/app/assets/components/paper-styles/classes/global.html +96 -0
- data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
- data/app/assets/components/paper-styles/classes/shadow.html +39 -0
- data/app/assets/components/paper-styles/classes/typography.html +171 -0
- data/app/assets/components/paper-styles/color.html +333 -0
- data/app/assets/components/paper-styles/default-theme.html +39 -0
- data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
- data/app/assets/components/paper-styles/paper-styles.html +17 -0
- data/app/assets/components/paper-styles/shadow.html +61 -0
- data/app/assets/components/paper-styles/typography.html +240 -0
- data/app/assets/components/paper-tabs/hero.svg +23 -0
- data/app/assets/components/paper-tabs/paper-tab.html +158 -0
- data/app/assets/components/paper-tabs/paper-tabs-icons.html +18 -0
- data/app/assets/components/paper-tabs/paper-tabs.html +483 -0
- data/app/assets/components/paper-toast/hero.svg +20 -0
- data/app/assets/components/paper-toast/paper-toast.html +164 -0
- data/app/assets/components/paper-toggle-button/hero.svg +22 -0
- data/app/assets/components/paper-toggle-button/paper-toggle-button.css +108 -0
- data/app/assets/components/paper-toggle-button/paper-toggle-button.html +183 -0
- data/app/assets/components/paper-toolbar/paper-toolbar.html +375 -0
- data/app/assets/components/polymer-gestures/Gruntfile.js +60 -0
- data/app/assets/components/polymer-gestures/banner.txt +9 -0
- data/app/assets/components/polymer-gestures/build.json +17 -0
- data/app/assets/components/polymer-gestures/conf/karma.conf.js +39 -0
- data/app/assets/components/polymer-gestures/package.json +20 -0
- data/app/assets/components/polymer-gestures/polymer-gestures.html +21 -0
- data/app/assets/components/polymer-gestures/polymer-gestures.js +46 -0
- data/app/assets/components/polymer-gestures/src/dispatcher.js +474 -0
- data/app/assets/components/polymer-gestures/src/eventFactory.js +127 -0
- data/app/assets/components/polymer-gestures/src/hold.js +129 -0
- data/app/assets/components/polymer-gestures/src/mouse.js +135 -0
- data/app/assets/components/polymer-gestures/src/ms.js +80 -0
- data/app/assets/components/polymer-gestures/src/pinch.js +186 -0
- data/app/assets/components/polymer-gestures/src/platform-events.js +39 -0
- data/app/assets/components/polymer-gestures/src/pointer.js +68 -0
- data/app/assets/components/polymer-gestures/src/pointermap.js +67 -0
- data/app/assets/components/polymer-gestures/src/scope.js +10 -0
- data/app/assets/components/polymer-gestures/src/tap.js +103 -0
- data/app/assets/components/polymer-gestures/src/targetfind.js +244 -0
- data/app/assets/components/polymer-gestures/src/touch-action.js +60 -0
- data/app/assets/components/polymer-gestures/src/touch.js +341 -0
- data/app/assets/components/polymer-gestures/src/track.js +230 -0
- data/app/assets/components/web-animations-js/web-animations-next-lite.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations-next.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations.min.js +17 -0
- data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
- data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
- data/app/assets/components/webcomponentsjs/package.json +31 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
- data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
- data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
- data/lib/polymer-paper-elements-rails.rb +2 -0
- data/lib/polymer-paper-elements-rails/engine.rb +4 -0
- data/lib/polymer-paper-elements-rails/version.rb +3 -0
- metadata +272 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
3
|
+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
4
|
+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
5
|
+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
6
|
+
* Code distributed by Google as part of the polymer project is also
|
|
7
|
+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Basic strategy: find the farthest apart points, use as diameter of circle
|
|
12
|
+
* react to size change and rotation of the chord
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @module pointer-gestures
|
|
17
|
+
* @submodule Events
|
|
18
|
+
* @class pinch
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Scale of the pinch zoom gesture
|
|
22
|
+
* @property scale
|
|
23
|
+
* @type Number
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Center X position of pointers causing pinch
|
|
27
|
+
* @property centerX
|
|
28
|
+
* @type Number
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Center Y position of pointers causing pinch
|
|
32
|
+
* @property centerY
|
|
33
|
+
* @type Number
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @module pointer-gestures
|
|
38
|
+
* @submodule Events
|
|
39
|
+
* @class rotate
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Angle (in degrees) of rotation. Measured from starting positions of pointers.
|
|
43
|
+
* @property angle
|
|
44
|
+
* @type Number
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* Center X position of pointers causing rotation
|
|
48
|
+
* @property centerX
|
|
49
|
+
* @type Number
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Center Y position of pointers causing rotation
|
|
53
|
+
* @property centerY
|
|
54
|
+
* @type Number
|
|
55
|
+
*/
|
|
56
|
+
(function(scope) {
|
|
57
|
+
var dispatcher = scope.dispatcher;
|
|
58
|
+
var eventFactory = scope.eventFactory;
|
|
59
|
+
var pointermap = new scope.PointerMap();
|
|
60
|
+
var RAD_TO_DEG = 180 / Math.PI;
|
|
61
|
+
var pinch = {
|
|
62
|
+
events: [
|
|
63
|
+
'down',
|
|
64
|
+
'up',
|
|
65
|
+
'move',
|
|
66
|
+
'cancel'
|
|
67
|
+
],
|
|
68
|
+
exposes: [
|
|
69
|
+
'pinchstart',
|
|
70
|
+
'pinch',
|
|
71
|
+
'pinchend',
|
|
72
|
+
'rotate'
|
|
73
|
+
],
|
|
74
|
+
defaultActions: {
|
|
75
|
+
'pinch': 'none',
|
|
76
|
+
'rotate': 'none'
|
|
77
|
+
},
|
|
78
|
+
reference: {},
|
|
79
|
+
down: function(inEvent) {
|
|
80
|
+
pointermap.set(inEvent.pointerId, inEvent);
|
|
81
|
+
if (pointermap.pointers() == 2) {
|
|
82
|
+
var points = this.calcChord();
|
|
83
|
+
var angle = this.calcAngle(points);
|
|
84
|
+
this.reference = {
|
|
85
|
+
angle: angle,
|
|
86
|
+
diameter: points.diameter,
|
|
87
|
+
target: scope.targetFinding.LCA(points.a.target, points.b.target)
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
this.firePinch('pinchstart', points.diameter, points);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
up: function(inEvent) {
|
|
94
|
+
var p = pointermap.get(inEvent.pointerId);
|
|
95
|
+
var num = pointermap.pointers();
|
|
96
|
+
if (p) {
|
|
97
|
+
if (num === 2) {
|
|
98
|
+
// fire 'pinchend' before deleting pointer
|
|
99
|
+
var points = this.calcChord();
|
|
100
|
+
this.firePinch('pinchend', points.diameter, points);
|
|
101
|
+
}
|
|
102
|
+
pointermap.delete(inEvent.pointerId);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
move: function(inEvent) {
|
|
106
|
+
if (pointermap.has(inEvent.pointerId)) {
|
|
107
|
+
pointermap.set(inEvent.pointerId, inEvent);
|
|
108
|
+
if (pointermap.pointers() > 1) {
|
|
109
|
+
this.calcPinchRotate();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
cancel: function(inEvent) {
|
|
114
|
+
this.up(inEvent);
|
|
115
|
+
},
|
|
116
|
+
firePinch: function(type, diameter, points) {
|
|
117
|
+
var zoom = diameter / this.reference.diameter;
|
|
118
|
+
var e = eventFactory.makeGestureEvent(type, {
|
|
119
|
+
bubbles: true,
|
|
120
|
+
cancelable: true,
|
|
121
|
+
scale: zoom,
|
|
122
|
+
centerX: points.center.x,
|
|
123
|
+
centerY: points.center.y,
|
|
124
|
+
_source: 'pinch'
|
|
125
|
+
});
|
|
126
|
+
this.reference.target.dispatchEvent(e);
|
|
127
|
+
},
|
|
128
|
+
fireRotate: function(angle, points) {
|
|
129
|
+
var diff = Math.round((angle - this.reference.angle) % 360);
|
|
130
|
+
var e = eventFactory.makeGestureEvent('rotate', {
|
|
131
|
+
bubbles: true,
|
|
132
|
+
cancelable: true,
|
|
133
|
+
angle: diff,
|
|
134
|
+
centerX: points.center.x,
|
|
135
|
+
centerY: points.center.y,
|
|
136
|
+
_source: 'pinch'
|
|
137
|
+
});
|
|
138
|
+
this.reference.target.dispatchEvent(e);
|
|
139
|
+
},
|
|
140
|
+
calcPinchRotate: function() {
|
|
141
|
+
var points = this.calcChord();
|
|
142
|
+
var diameter = points.diameter;
|
|
143
|
+
var angle = this.calcAngle(points);
|
|
144
|
+
if (diameter != this.reference.diameter) {
|
|
145
|
+
this.firePinch('pinch', diameter, points);
|
|
146
|
+
}
|
|
147
|
+
if (angle != this.reference.angle) {
|
|
148
|
+
this.fireRotate(angle, points);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
calcChord: function() {
|
|
152
|
+
var pointers = [];
|
|
153
|
+
pointermap.forEach(function(p) {
|
|
154
|
+
pointers.push(p);
|
|
155
|
+
});
|
|
156
|
+
var dist = 0;
|
|
157
|
+
// start with at least two pointers
|
|
158
|
+
var points = {a: pointers[0], b: pointers[1]};
|
|
159
|
+
var x, y, d;
|
|
160
|
+
for (var i = 0; i < pointers.length; i++) {
|
|
161
|
+
var a = pointers[i];
|
|
162
|
+
for (var j = i + 1; j < pointers.length; j++) {
|
|
163
|
+
var b = pointers[j];
|
|
164
|
+
x = Math.abs(a.clientX - b.clientX);
|
|
165
|
+
y = Math.abs(a.clientY - b.clientY);
|
|
166
|
+
d = x + y;
|
|
167
|
+
if (d > dist) {
|
|
168
|
+
dist = d;
|
|
169
|
+
points = {a: a, b: b};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
x = Math.abs(points.a.clientX + points.b.clientX) / 2;
|
|
174
|
+
y = Math.abs(points.a.clientY + points.b.clientY) / 2;
|
|
175
|
+
points.center = { x: x, y: y };
|
|
176
|
+
points.diameter = dist;
|
|
177
|
+
return points;
|
|
178
|
+
},
|
|
179
|
+
calcAngle: function(points) {
|
|
180
|
+
var x = points.a.clientX - points.b.clientX;
|
|
181
|
+
var y = points.a.clientY - points.b.clientY;
|
|
182
|
+
return (360 + Math.atan2(y, x) * RAD_TO_DEG) % 360;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
dispatcher.registerGesture('pinch', pinch);
|
|
186
|
+
})(window.PolymerGestures);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
3
|
+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
4
|
+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
5
|
+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
6
|
+
* Code distributed by Google as part of the polymer project is also
|
|
7
|
+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This module contains the handlers for native platform events.
|
|
12
|
+
* From here, the dispatcher is called to create unified pointer events.
|
|
13
|
+
* Included are touch events (v1), mouse events, and MSPointerEvents.
|
|
14
|
+
*/
|
|
15
|
+
(function(scope) {
|
|
16
|
+
|
|
17
|
+
var dispatcher = scope.dispatcher;
|
|
18
|
+
var nav = window.navigator;
|
|
19
|
+
|
|
20
|
+
if (window.PointerEvent) {
|
|
21
|
+
dispatcher.registerSource('pointer', scope.pointerEvents);
|
|
22
|
+
} else if (nav.msPointerEnabled) {
|
|
23
|
+
dispatcher.registerSource('ms', scope.msEvents);
|
|
24
|
+
} else {
|
|
25
|
+
dispatcher.registerSource('mouse', scope.mouseEvents);
|
|
26
|
+
if (window.ontouchstart !== undefined) {
|
|
27
|
+
dispatcher.registerSource('touch', scope.touchEvents);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Work around iOS bugs https://bugs.webkit.org/show_bug.cgi?id=135628 and https://bugs.webkit.org/show_bug.cgi?id=136506
|
|
32
|
+
var ua = navigator.userAgent;
|
|
33
|
+
var IS_IOS = ua.match(/iPad|iPhone|iPod/) && 'ontouchstart' in window;
|
|
34
|
+
|
|
35
|
+
dispatcher.IS_IOS = IS_IOS;
|
|
36
|
+
scope.touchEvents.IS_IOS = IS_IOS;
|
|
37
|
+
|
|
38
|
+
dispatcher.register(document, true);
|
|
39
|
+
})(window.PolymerGestures);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
3
|
+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
4
|
+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
5
|
+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
6
|
+
* Code distributed by Google as part of the polymer project is also
|
|
7
|
+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
(function(scope) {
|
|
11
|
+
var dispatcher = scope.dispatcher;
|
|
12
|
+
var pointermap = dispatcher.pointermap;
|
|
13
|
+
var pointerEvents = {
|
|
14
|
+
events: [
|
|
15
|
+
'pointerdown',
|
|
16
|
+
'pointermove',
|
|
17
|
+
'pointerup',
|
|
18
|
+
'pointercancel'
|
|
19
|
+
],
|
|
20
|
+
prepareEvent: function(inEvent) {
|
|
21
|
+
var e = dispatcher.cloneEvent(inEvent);
|
|
22
|
+
e._source = 'pointer';
|
|
23
|
+
return e;
|
|
24
|
+
},
|
|
25
|
+
register: function(target) {
|
|
26
|
+
dispatcher.listen(target, this.events);
|
|
27
|
+
},
|
|
28
|
+
unregister: function(target) {
|
|
29
|
+
if (target.nodeType === Node.DOCUMENT_NODE) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
dispatcher.unlisten(target, this.events);
|
|
33
|
+
},
|
|
34
|
+
cleanup: function(id) {
|
|
35
|
+
pointermap['delete'](id);
|
|
36
|
+
},
|
|
37
|
+
pointerdown: function(inEvent) {
|
|
38
|
+
var e = this.prepareEvent(inEvent);
|
|
39
|
+
e.target = scope.findTarget(inEvent);
|
|
40
|
+
pointermap.set(e.pointerId, e.target);
|
|
41
|
+
dispatcher.down(e);
|
|
42
|
+
},
|
|
43
|
+
pointermove: function(inEvent) {
|
|
44
|
+
var target = pointermap.get(inEvent.pointerId);
|
|
45
|
+
if (target) {
|
|
46
|
+
var e = this.prepareEvent(inEvent);
|
|
47
|
+
e.target = target;
|
|
48
|
+
dispatcher.move(e);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
pointerup: function(inEvent) {
|
|
52
|
+
var e = this.prepareEvent(inEvent);
|
|
53
|
+
e.relatedTarget = scope.findTarget(inEvent);
|
|
54
|
+
e.target = pointermap.get(e.pointerId);
|
|
55
|
+
dispatcher.up(e);
|
|
56
|
+
this.cleanup(inEvent.pointerId);
|
|
57
|
+
},
|
|
58
|
+
pointercancel: function(inEvent) {
|
|
59
|
+
var e = this.prepareEvent(inEvent);
|
|
60
|
+
e.relatedTarget = scope.findTarget(inEvent);
|
|
61
|
+
e.target = pointermap.get(e.pointerId);
|
|
62
|
+
dispatcher.cancel(e);
|
|
63
|
+
this.cleanup(inEvent.pointerId);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
scope.pointerEvents = pointerEvents;
|
|
68
|
+
})(window.PolymerGestures);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
3
|
+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
4
|
+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
5
|
+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
6
|
+
* Code distributed by Google as part of the polymer project is also
|
|
7
|
+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This module implements an map of pointer states
|
|
12
|
+
*/
|
|
13
|
+
(function(scope) {
|
|
14
|
+
var USE_MAP = window.Map && window.Map.prototype.forEach;
|
|
15
|
+
var POINTERS_FN = function(){ return this.size; };
|
|
16
|
+
function PointerMap() {
|
|
17
|
+
if (USE_MAP) {
|
|
18
|
+
var m = new Map();
|
|
19
|
+
m.pointers = POINTERS_FN;
|
|
20
|
+
return m;
|
|
21
|
+
} else {
|
|
22
|
+
this.keys = [];
|
|
23
|
+
this.values = [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
PointerMap.prototype = {
|
|
28
|
+
set: function(inId, inEvent) {
|
|
29
|
+
var i = this.keys.indexOf(inId);
|
|
30
|
+
if (i > -1) {
|
|
31
|
+
this.values[i] = inEvent;
|
|
32
|
+
} else {
|
|
33
|
+
this.keys.push(inId);
|
|
34
|
+
this.values.push(inEvent);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
has: function(inId) {
|
|
38
|
+
return this.keys.indexOf(inId) > -1;
|
|
39
|
+
},
|
|
40
|
+
'delete': function(inId) {
|
|
41
|
+
var i = this.keys.indexOf(inId);
|
|
42
|
+
if (i > -1) {
|
|
43
|
+
this.keys.splice(i, 1);
|
|
44
|
+
this.values.splice(i, 1);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
get: function(inId) {
|
|
48
|
+
var i = this.keys.indexOf(inId);
|
|
49
|
+
return this.values[i];
|
|
50
|
+
},
|
|
51
|
+
clear: function() {
|
|
52
|
+
this.keys.length = 0;
|
|
53
|
+
this.values.length = 0;
|
|
54
|
+
},
|
|
55
|
+
// return value, key, map
|
|
56
|
+
forEach: function(callback, thisArg) {
|
|
57
|
+
this.values.forEach(function(v, i) {
|
|
58
|
+
callback.call(thisArg, v, this.keys[i], this);
|
|
59
|
+
}, this);
|
|
60
|
+
},
|
|
61
|
+
pointers: function() {
|
|
62
|
+
return this.keys.length;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
scope.PointerMap = PointerMap;
|
|
67
|
+
})(window.PolymerGestures);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
4
|
+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
5
|
+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
6
|
+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
7
|
+
* Code distributed by Google as part of the polymer project is also
|
|
8
|
+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
9
|
+
*/
|
|
10
|
+
window.PolymerGestures = {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
3
|
+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
4
|
+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
5
|
+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
6
|
+
* Code distributed by Google as part of the polymer project is also
|
|
7
|
+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This event is fired when a pointer quickly goes down and up, and is used to
|
|
12
|
+
* denote activation.
|
|
13
|
+
*
|
|
14
|
+
* Any gesture event can prevent the tap event from being created by calling
|
|
15
|
+
* `event.preventTap`.
|
|
16
|
+
*
|
|
17
|
+
* Any pointer event can prevent the tap by setting the `tapPrevented` property
|
|
18
|
+
* on itself.
|
|
19
|
+
*
|
|
20
|
+
* @module PointerGestures
|
|
21
|
+
* @submodule Events
|
|
22
|
+
* @class tap
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* X axis position of the tap.
|
|
26
|
+
* @property x
|
|
27
|
+
* @type Number
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Y axis position of the tap.
|
|
31
|
+
* @property y
|
|
32
|
+
* @type Number
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* Type of the pointer that made the tap.
|
|
36
|
+
* @property pointerType
|
|
37
|
+
* @type String
|
|
38
|
+
*/
|
|
39
|
+
(function(scope) {
|
|
40
|
+
var dispatcher = scope.dispatcher;
|
|
41
|
+
var eventFactory = scope.eventFactory;
|
|
42
|
+
var pointermap = new scope.PointerMap();
|
|
43
|
+
var tap = {
|
|
44
|
+
events: [
|
|
45
|
+
'down',
|
|
46
|
+
'up'
|
|
47
|
+
],
|
|
48
|
+
exposes: [
|
|
49
|
+
'tap'
|
|
50
|
+
],
|
|
51
|
+
down: function(inEvent) {
|
|
52
|
+
if (inEvent.isPrimary && !inEvent.tapPrevented) {
|
|
53
|
+
pointermap.set(inEvent.pointerId, {
|
|
54
|
+
target: inEvent.target,
|
|
55
|
+
buttons: inEvent.buttons,
|
|
56
|
+
x: inEvent.clientX,
|
|
57
|
+
y: inEvent.clientY
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
shouldTap: function(e, downState) {
|
|
62
|
+
var tap = true;
|
|
63
|
+
if (e.pointerType === 'mouse') {
|
|
64
|
+
// only allow left click to tap for mouse
|
|
65
|
+
tap = (e.buttons ^ 1) && (downState.buttons & 1);
|
|
66
|
+
}
|
|
67
|
+
return tap && !e.tapPrevented;
|
|
68
|
+
},
|
|
69
|
+
up: function(inEvent) {
|
|
70
|
+
var start = pointermap.get(inEvent.pointerId);
|
|
71
|
+
if (start && this.shouldTap(inEvent, start)) {
|
|
72
|
+
// up.relatedTarget is target currently under finger
|
|
73
|
+
var t = scope.targetFinding.LCA(start.target, inEvent.relatedTarget);
|
|
74
|
+
if (t) {
|
|
75
|
+
var e = eventFactory.makeGestureEvent('tap', {
|
|
76
|
+
bubbles: true,
|
|
77
|
+
cancelable: true,
|
|
78
|
+
x: inEvent.clientX,
|
|
79
|
+
y: inEvent.clientY,
|
|
80
|
+
detail: inEvent.detail,
|
|
81
|
+
pointerType: inEvent.pointerType,
|
|
82
|
+
pointerId: inEvent.pointerId,
|
|
83
|
+
altKey: inEvent.altKey,
|
|
84
|
+
ctrlKey: inEvent.ctrlKey,
|
|
85
|
+
metaKey: inEvent.metaKey,
|
|
86
|
+
shiftKey: inEvent.shiftKey,
|
|
87
|
+
_source: 'tap'
|
|
88
|
+
});
|
|
89
|
+
t.dispatchEvent(e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
pointermap.delete(inEvent.pointerId);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
// patch eventFactory to remove id from tap's pointermap for preventTap calls
|
|
96
|
+
eventFactory.preventTap = function(e) {
|
|
97
|
+
return function() {
|
|
98
|
+
e.tapPrevented = true;
|
|
99
|
+
pointermap.delete(e.pointerId);
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
dispatcher.registerGesture('tap', tap);
|
|
103
|
+
})(window.PolymerGestures);
|