Skip to content

Commit

Permalink
OnLoad checks now for supporting animations. .animations-on css-context
Browse files Browse the repository at this point in the history
  • Loading branch information
viT-1 committed Sep 22, 2016
1 parent 5ed205c commit 55f8a25
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion css/original/base-layScreen-mobile.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**** Touch-devices */
*[ly-touch = 'true'] .iYandex[ly-userName = 'firstLetter'] {
.touch-on .iYandex[ly-userName = 'firstLetter'] {
font-weight: bolder;
}
/* Touch-devices ****/
Expand Down
4 changes: 3 additions & 1 deletion css/original/iGallery.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
.iGallery[ly-hldDetails ~= 'bhvrHover'] {
max-height: 0;
height: 0;

}

.animate-on .iGallery[ly-hldDetails ~= 'bhvrHover'] {
-webkit-animation: fadeOut 0.3s ease;
animation: fadeOut 0.3s ease;
}
Expand Down
38 changes: 32 additions & 6 deletions js/onload.js
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;
}
2 changes: 1 addition & 1 deletion xsl/original/base-layScreen.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/>

<xsl:template match="html">
<html class="no-js {@class}">
<html class="js-off {@class}">
<xsl:apply-templates select="@* | *" />
</html>
</xsl:template>
Expand Down

0 comments on commit 55f8a25

Please sign in to comment.