代码拉取完成,页面将自动刷新
(function ($) {
$.fn.horizSplitBox = function() {
var $box = $(this);
var $cover = $box.find('.cover');
var $toggle = $box.find('.toggle-handle');
var mouseX, toggleLeft, draggable = false;
function getPageX(e) {
if (typeof e.pageX == 'undefined' ) {
return e.touches[0].pageX;
}
return e.pageX;
}
$(document).on('mousemove touchmove', function (e) {
if (!draggable) {
return;
}
var left = toggleLeft + getPageX(e) - mouseX;
var width = $toggle.parent().width() - $toggle.width();
left = Math.max(Math.min(left, width), 0);
$toggle.css('left', left);
$cover.css('width', left);
});
$(document).on('mouseup touchend', function (e) {
draggable = false;
$box.css('user-select', '');
});
$toggle.on('mousedown touchstart', function (e) {
draggable = true;
mouseX = getPageX(e);
toggleLeft = $toggle.position().left;
$box.css('user-select', 'none');
});
return $box;
}
})(jQuery);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。