-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolymer-gesture-scroll.html
74 lines (57 loc) · 2.34 KB
/
polymer-gesture-scroll.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<link rel="import" href="../polymer/polymer.html">
<script src="../tracking.js/build/tracking-min.js"></script>
<script src="../tracking.js/build/data/face.js"></script>
<script src="../tracking.js/build/data/eye.js"></script>
<script src="../tracking.js/build/data/mouth.js"></script>
<!--
Element providing solution to smart scrolling using gesture.
##### Example
<polymer-gesture-scroll></polymer-gesture-scroll>
@element polymer-gesture-scroll
@demo http://f0ysal.github.io/bower_components/polymer-gesture-scroll/demo.html
@blurb Element providing solution to smart scrolling using gesture.
@status alpha
@homepage https://github.com/f0ysal/Polymer-Gesture-Scroll
-->
<polymer-element name="polymer-gesture-scroll" attributes="">
<template>
<video id="video" width="100" height="100" preload autoplay loop muted>
</video>
</template>
<script>
Polymer('polymer-gesture-scroll', {
author: 'Foysal Osmany',
fancy: false,
domReady: function() {
var video = this.$.video;
var scrollYaxis = window.scrollY;
var initYaxis = 0;
var objects = new tracking.ObjectTracker(['face', 'eye', 'mouth']);
objects.on('track', function(event) {
if (event.data.length === 0) {
console.log('please try again');
}
else {
event.data.forEach(function(rect) {
if(rect.y - initYaxis > 10 || initYaxis - rect.y > 10)
{
initYaxis = rect.y
}
if(rect.y > initYaxis)
{
window.scrollTo(0,scrollYaxis+=10);
}
if(rect.y < initYaxis && scrollYaxis >=0 )
{
window.scrollTo(0,scrollYaxis-=10);
}
console.log(initYaxis, scrollYaxis);
lastYaxis = rect.y;
});
}
});
tracking.track(video, objects, { camera: true });
}
});
</script>
</polymer-element>