function getEle(selector) {
return document.querySelector(selector);
}
function getAllEle(selector) {
return document.querySelectorAll(selector);
}
function getCls(element) {//获取样式class
return element.className;
}
function setCls(element, cls) {//设置样式
element.className=cls ;
}
function addCls(element, cls) {//添加样式
var baseCls = getCls(element);
if (baseCls.indexOf(cls) === -1) {
setCls(element, baseCls + ' ' + cls);
}
}
function delCls(element, cls) {//删除样式
var baseCls = getCls(element);
if (baseCls.indexOf(cls) > -1) {
setCls(element, baseCls.split(cls).join(' ').replace('/\s+/g', ' '));
}
}
function setEleInit(screen) {
var eleInit = setScreenAnimate[screen];
for (var i = 0; i < eleInit.length; i++) {
var ele = document.querySelector(eleInit[i]);
var baseCls = getCls(ele);
setCls(ele[i], baseCls + ' ' + baseCls + '_init');
}
}
function setEleDone(screen) {
var eleInit = setScreenAnimate[screen];
for (var i = 0; i < eleInit.length; i++) {
var ele = document.querySelector(eleInit[i]);
var baseCls = getCls(ele);
setCls(ele[i], baseCls.replace('init', 'done'));
}
}
var setScreenAnimate = {
'.screen-1': ['.screen-1__heading', '.screen-1__subheading'],
'.screen-2': ['.screen-2__heading', '.screen-2__subheading', '.screen-2__tip', '.screen-2__pic-2', '.screen-2__pic-3'],
'.screen-3': ['.screen-3__heading', '.screen-3__subheading', '.screen-3__tip', '.screen-3__pic', '.screen-3__feature'],
'.screen-4': ['.screen-4__heading', '.screen-4__subheading', '.screen-4__tip', '.screen-4__item-1', '.screen-4__item-2', '.screen-4__item-3', '.screen-4__item-4'],
'.screen-5': ['.screen-5__heading', '.screen-5__subheading', '.screen-5__tip', '.screen-5__pic']
};
var k;
for (k in setScreenAnimate) {
setEleInit(k);
}
习惯受伤
相关分类