@pathable/css-element-queries
Advanced tools
Comparing version 0.3.2 to 0.3.3
{ | ||
"name": "@pathable/css-element-queries", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "CSS-Element-Queries Polyfill. proof-of-concept for high-speed element dimension/media queries in valid css.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -384,5 +384,45 @@ /** | ||
*/ | ||
this.init = function(withTracking) { | ||
this.init = function (withTracking) { | ||
trackingActive = typeof withTracking === 'undefined' ? false : withTracking; | ||
var animationStart = 'animationstart'; | ||
if (typeof document.documentElement.style['webkitAnimationName'] !== 'undefined') { | ||
animationStart = 'webkitAnimationStart'; | ||
} else if (typeof document.documentElement.style['MozAnimationName'] !== 'undefined') { | ||
animationStart = 'mozanimationstart'; | ||
} else if (typeof document.documentElement.style['OAnimationName'] !== 'undefined') { | ||
animationStart = 'oanimationstart'; | ||
} | ||
document.body.addEventListener(animationStart, function (e) { | ||
var element = e.target; | ||
var styles = element && window.getComputedStyle(element, null); | ||
var animationName = styles && styles.getPropertyValue('animation-name'); | ||
var requiresSetup = animationName && (-1 !== animationName.indexOf('element-queries')); | ||
if (requiresSetup) { | ||
element.elementQueriesSensor = new ResizeSensor(element, function () { | ||
if (element.elementQueriesSetupInformation) { | ||
element.elementQueriesSetupInformation.call(); | ||
} | ||
}); | ||
var sensorStyles = window.getComputedStyle(element.resizeSensor, null); | ||
var id = sensorStyles.getPropertyValue('min-width'); | ||
id = parseInt(id.replace('px', '')); | ||
setupElement(e.target, idToSelectorMapping[id]); | ||
} | ||
}); | ||
if (!defaultCssInjected) { | ||
cssStyleElement = document.createElement('style'); | ||
cssStyleElement.type = 'text/css'; | ||
cssStyleElement.innerHTML = '[responsive-image] > img, [data-responsive-image] {overflow: hidden; padding: 0; } [responsive-image] > img, [data-responsive-image] > img {width: 100%;}'; | ||
//safari wants at least one rule in keyframes to start working | ||
cssStyleElement.innerHTML += '\n@keyframes element-queries { 0% { visibility: inherit; } }'; | ||
document.getElementsByTagName('head')[0].appendChild(cssStyleElement); | ||
defaultCssInjected = true; | ||
} | ||
for (var i = 0, j = document.styleSheets.length; i < j; i++) { | ||
@@ -389,0 +429,0 @@ try { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
48661
12
677
1