MCPcopy
hub / github.com/jamiebuilds/spectacle-code-slide / scrollToElement

Function scrollToElement

src/scrollToElement.js:14–41  ·  view source on GitHub ↗
(element, x, y, options)

Source from the content-addressed store, hash-verified

12}
13
14function scrollToElement(element, x, y, options) {
15 options = options || {};
16
17 var start = scroll(element);
18
19 var tween = Tween(start)
20 .ease(options.ease || 'out-circ')
21 .to({ top: y, left: x })
22 .duration(options.duration || 1000);
23
24 tween.update(function(o){
25 element.scrollTop = o.top | 0;
26 element.scrollLeft = o.left | 0;
27 });
28
29 tween.on('end', function(){
30 animate = function(){};
31 });
32
33 function animate() {
34 raf(animate);
35 tween.update();
36 }
37
38 animate();
39
40 return tween;
41}
42
43module.exports = scrollToElement;

Callers 1

CodeSlide.jsFile · 0.85

Calls 2

scrollFunction · 0.85
animateFunction · 0.85

Tested by

no test coverage detected