本文整理匯總了TypeScript中app/utils/toggleStyle.toggleStyle函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript toggleStyle函數的具體用法?TypeScript toggleStyle怎麽用?TypeScript toggleStyle使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了toggleStyle函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: addHoverEffect
export function addHoverEffect(domElement, style) {
assert(_.isElement(domElement), 'addHoverEffect expects the first argument to be a DOM element');
assert(_.isPlainObject(style), 'addHoverEffect expects the second argument, style, to be a hash');
toggleStyle(domElement, style, 'mouseenter', 'mouseleave');
domElement.setAttribute('has-on-hover-effect', '');
}
示例2: it
it('works', function() {
var style = {
borderColor: 'blue'
};
var onEventName = 'focusin';
var offEventName = 'focusout';
toggleStyle(domElement, style, onEventName, offEventName);
domElement.dispatchEvent(new Event(onEventName));
assert.equal(domElement.style.borderColor, style.borderColor, 'applies the given style on the “on” event');
domElement.dispatchEvent(new Event(offEventName));
assert.equal(domElement.style.borderColor, initialStyle.borderColor, 'returns the initial style on the “off” event');
});
示例3: toggleStyle
assert.throws(function() {
toggleStyle(domElement, style, 'mouseenter', 42);
},
示例4: addFocusEffect
export function addFocusEffect(domElement, style) {
toggleStyle(domElement, style, 'focus', 'blur');
domElement.setAttribute('has-on-focus-effect', '');
}