本文整理汇总了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', '');
}