简体   繁体   English

toggleClass缓动仅适用于缓和

[英]toggleClass easing only works on ease out

I have created a search-bar that eases in and out of hidden and visible using fixed widths. 我创建了一个搜索栏,可以使用固定宽度轻松地显示和隐藏和隐藏内容。 I'm using jQuery UI to toggle the widths with easing, however, I'm having issues with getting the widths to ease in properly. 我正在使用jQuery UI来通过缓动来切换宽度,但是,在适当地减小宽度方面存在问题。 Rather than easing in, it stays invisible until the last minute and then appears. 它不会缓和,而是保持不可见直到最后一分钟,然后出现。 Easing out works as it should. 减轻负担是应该的。 Fiddle here: 在这里摆弄:

http://jsfiddle.net/mLqhqcyb/ http://jsfiddle.net/mLqhqcyb/

This issue is happening across all browsers. 所有浏览器均会发生此问题。

var container = $('.left-container');
var button = $('.search-button');

$( document ).ready( function(){

    button.click( function(){
        console.log( 'Hello' );
        container.toggleClass( "hidden", 300, "easeInOutExpo" );
    });
}

You are using class hidden which is also a class in bootstrap and its getting styles from it too. 您正在使用hidden类,它也是引导程序中的类,它也从中获取样式。

Rename the class and it will work. 重命名该类,它将起作用。

.custom-hidden {
    width: 0px;
    overflow: hidden;
}

button.click(function () {
        console.log('Hello');
        container.toggleClass("custom-hidden", 300, "easeInOutExpo");
}

Fiddle 小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM