From 55f8a2517c0d98860e0dc7b9a07fd7e53bf5090e Mon Sep 17 00:00:00 2001 From: Vitaly Pinchuk Date: Thu, 22 Sep 2016 12:13:03 +0300 Subject: [PATCH] OnLoad checks now for supporting animations. .animations-on css-context https://github.com/viT-1/larinayoga/issues/13 --- css/original/base-layScreen-mobile.css | 2 +- css/original/iGallery.css | 4 ++- js/onload.js | 38 ++++++++++++++++++++++---- xsl/original/base-layScreen.xsl | 2 +- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/css/original/base-layScreen-mobile.css b/css/original/base-layScreen-mobile.css index a4bed7a..6ea5007 100644 --- a/css/original/base-layScreen-mobile.css +++ b/css/original/base-layScreen-mobile.css @@ -1,5 +1,5 @@ /**** Touch-devices */ -*[ly-touch = 'true'] .iYandex[ly-userName = 'firstLetter'] { +.touch-on .iYandex[ly-userName = 'firstLetter'] { font-weight: bolder; } /* Touch-devices ****/ diff --git a/css/original/iGallery.css b/css/original/iGallery.css index d066d79..df4e823 100644 --- a/css/original/iGallery.css +++ b/css/original/iGallery.css @@ -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; } diff --git a/js/onload.js b/js/onload.js index 33d892b..e93aeb0 100644 --- a/js/onload.js +++ b/js/onload.js @@ -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; } \ No newline at end of file diff --git a/xsl/original/base-layScreen.xsl b/xsl/original/base-layScreen.xsl index be67141..a8e4d47 100644 --- a/xsl/original/base-layScreen.xsl +++ b/xsl/original/base-layScreen.xsl @@ -15,7 +15,7 @@ /> - +