contao-utils-bundle
Advanced tools
Comparing version 1.0.5 to 1.1.0
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
## [1.1.0] - 2018-12-14 | ||
### Added | ||
- dom.scrollTo | ||
- dom.elementInViewport | ||
## [1.0.5] - 2018-10-29 | ||
@@ -5,0 +11,0 @@ |
@@ -12,2 +12,32 @@ module.exports = { | ||
}, | ||
scrollTo: function(element, offset = 0, delay = 0, force = false) { | ||
let rect = element.getBoundingClientRect(); | ||
let scrollPosition = (rect.top + window.pageYOffset - offset); | ||
setTimeout(() => { | ||
if (!this.elementInViewport(element) || force === true) | ||
window.scrollTo({ | ||
'top': scrollPosition, | ||
'behavior': 'smooth', | ||
}); | ||
}, delay); | ||
}, | ||
elementInViewport: function(el) { | ||
let top = el.offsetTop; | ||
let left = el.offsetLeft; | ||
let width = el.offsetWidth; | ||
let height = el.offsetHeight; | ||
while (el.offsetParent) { | ||
el = el.offsetParent; | ||
top += el.offsetTop; | ||
left += el.offsetLeft; | ||
} | ||
return ( | ||
top < (window.pageYOffset + window.innerHeight) && | ||
left < (window.pageXOffset + window.innerWidth) && | ||
(top + height) > window.pageYOffset && | ||
(left + width) > window.pageXOffset | ||
); | ||
}, | ||
}; |
{ | ||
"name": "contao-utils-bundle", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "This package contains the frontend assets of the composer bundle heimrichhannot/contao-utils-bundle.", | ||
@@ -5,0 +5,0 @@ "main": "js/utils-bundle", |
# Contao Utils Bundle Assets | ||
This package contains the frontend assets of the composer bundle heimrichhannot/contao-utils-bundle. | ||
This package contains the frontend assets of the composer bundle [heimrichhannot/contao-utils-bundle](https://github.com/heimrichhannot/contao-utils-bundle). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6663
180