@builder.io/sdk
Advanced tools
Comparing version 0.0.133 to 0.0.134
@@ -627,9 +627,11 @@ 'use strict'; | ||
} | ||
var triggered = false; | ||
// TODO: roll all of these in one for more efficiency of checking all the rects | ||
var onScroll = throttle(function () { | ||
if (isScrolledIntoView(element)) { | ||
if (!triggered && isScrolledIntoView(element)) { | ||
triggered = true; | ||
Object.assign(element.style, animation.steps[1].styles); | ||
document.removeEventListener('scroll', onScroll); | ||
} | ||
}, 100); | ||
}, 100, { leading: false }); | ||
// TODO: fully in view or partially | ||
@@ -639,3 +641,5 @@ function isScrolledIntoView(elem) { | ||
// TODO: partial in view? or what if element is larger than screen itself | ||
return rect.top > 0 && rect.bottom < window.innerHeight; | ||
return ((rect.top > 0 && rect.bottom < window.innerHeight) || // element fits within the screen and is fully on screen (not hanging off at all) | ||
(rect.top < 0 && rect.bottom > window.innerHeight) // element is larger than the screen and hangs over the top and bottom | ||
); | ||
} | ||
@@ -642,0 +646,0 @@ var defaultState = animation.steps[0].styles; |
@@ -621,9 +621,11 @@ import uniqueSelector from 'unique-selector'; | ||
} | ||
var triggered = false; | ||
// TODO: roll all of these in one for more efficiency of checking all the rects | ||
var onScroll = throttle(function () { | ||
if (isScrolledIntoView(element)) { | ||
if (!triggered && isScrolledIntoView(element)) { | ||
triggered = true; | ||
Object.assign(element.style, animation.steps[1].styles); | ||
document.removeEventListener('scroll', onScroll); | ||
} | ||
}, 100); | ||
}, 100, { leading: false }); | ||
// TODO: fully in view or partially | ||
@@ -633,3 +635,5 @@ function isScrolledIntoView(elem) { | ||
// TODO: partial in view? or what if element is larger than screen itself | ||
return rect.top > 0 && rect.bottom < window.innerHeight; | ||
return ((rect.top > 0 && rect.bottom < window.innerHeight) || // element fits within the screen and is fully on screen (not hanging off at all) | ||
(rect.top < 0 && rect.bottom > window.innerHeight) // element is larger than the screen and hangs over the top and bottom | ||
); | ||
} | ||
@@ -636,0 +640,0 @@ var defaultState = animation.steps[0].styles; |
{ | ||
"name": "@builder.io/sdk", | ||
"version": "0.0.133", | ||
"version": "0.0.134", | ||
"browser": "./dist/index.umd.min.js", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.cjs.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1088118
15038