Скрытая функция, которую вы используете в настоящее время, является расширением, включенным в пользовательский интерфейс jQuery. . Эта функция вызывает внутренне функцию анимации (см jQuery UI hide)
Для того, чтобы получить эффект, который вы ищете здесь сниппет:
$(function() {
$('div').on('click', function() {
$(this).hide('size', {
to: {
height: 0,
width: 0,
marginLeft: parseInt($(this).css('marginLeft'), 10) == 0 ? $(this).outerWidth() : 0
}
},
function() {
$(this).remove();
});
});
});
div {
cursor: pointer;
width: 200px;
height: 300px;
background-color: #3b85c3;
}
<link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<div>
</div>
Использование, вместо этого, стандарт animate Функция здесь соответствует фрагменту:
$(function() {
$('div').on('click', function() {
$(this).animate({
height: 'toggle',
width: 'toggle',
marginLeft: parseInt($(this).css('marginLeft'), 10) == 0 ? $(this).outerWidth() : 0
}, function() {
$(this).remove();
});
});
});
div {
cursor: pointer;
width: 200px;
height: 300px;
background-color: #3b85c3;
}
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<div>
</div>
Для 'size' эффекта для' .hide Jquery UI (в) 'метод, вы можете использовать' origin' вариант, а не 'в' вариант. То есть вы можете использовать '{origin: ['top', 'right']}' для аргумента 'options'. [jsfiddle] (http://fiddle.jshell.net/n3k4kzfc/) –
Большое спасибо. – gaetanoM
отлично! Спасибо! – Philip