-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OnLoad checks now for supporting animations. .animations-on css-context
- Loading branch information
Showing
4 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,38 @@ | ||
var strIsSupportedPostfix = 'on', | ||
strDoesntSupportedPostfix = 'off'; | ||
|
||
function initBodySettings(){ | ||
var o_html = document.documentElement; | ||
|
||
removeAttrVal( o_html, 'class', 'no-js' ); | ||
toggleAttrVal( o_html, 'class', 'js-off', 'js-on' ); | ||
addAttrVal( o_html, 'class', 'touch-' + isTouchSupported() ); | ||
addAttrVal( o_html, 'class', 'animations-' + isAnimationsSupported() ); | ||
} | ||
|
||
function isTouchSupported() { | ||
var supports = Boolean( | ||
( 'ontouchstart' in window) | ||
|| (navigator.msMaxTouchPoints > 0) | ||
|| (window.DocumentTouch && document instanceof DocumentTouch) | ||
); | ||
|
||
if (( 'ontouchstart' in window) || (navigator.msMaxTouchPoints > 0) || (window.DocumentTouch && document instanceof DocumentTouch)){ | ||
addAttrVal( o_html, 'ly-touch', 'true' ); | ||
} | ||
else { | ||
addAttrVal( o_html, 'ly-touch', 'false' ); | ||
return supports ? strIsSupportedPostfixString : strDoesntSupportedPostfix; | ||
} | ||
|
||
function isAnimationsSupported() { | ||
var domPrefixes = 'Webkit Moz O ms Khtml'.split(' '), | ||
elm = document.documentElement, | ||
supports = false; | ||
|
||
if( elm.style.animationName ) { supports = true; } | ||
if( supports === false ) { | ||
for( var i = 0; i < domPrefixes.length; i++ ) { | ||
if( elm.style[ domPrefixes[i] + 'AnimationName' ] !== undefined ) { | ||
supports = true; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return supports ? strIsSupportedPostfixString : strDoesntSupportedPostfix; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters