【问题标题】:jQuery Ui Draggable no scrolling with flexboxjQuery Ui Draggable 没有使用 flexbox 滚动
【发布时间】:2015-10-08 10:12:00
【问题描述】:

我想用 jquery Ui 可拖放/可拖放对一些容器进行排序。

由于元素的水平直线,我使用display: flex。这在将项目添加到我的列表时效果很好。

但我的列表可能比视口大。所以我需要在拖动元素时滚动。

这是我的小提琴:http://jsfiddle.net/r9vc9uyd/

HTML

<div class="mainwrap">
        <div class="flexwrap">
            <div class="item item--small"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>
            <div class="item"><p>Loremlorem</p></div>

        </div>
    </div>

CSS

.mainwrap {
            width: 500px;
            display: block;
            background: yellow;
            height: auto;
            overflow-x: scroll;
            -webkit-overflow-scrolling: touch;
        }

        .flexwrap {
            zoom: 1;
            display: flex;
            flex-direction: row;
            padding: 10px 5px;

        }

        .item {
            width: 100px;
            margin: 0 5px;
            padding: 10px;
            background: #bada55;
            flex-grow: 0;
            flex-shrink: 0;
            flex-basis: 1;
            word-wrap: break-word;

        }
        .item--small {
            flex-shrink: 1;
            background: mediumvioletred;
            width: 50px;
        }

Javascript

$("document").ready(function() {
    $(".item").draggable({
        helper: 'clone',
        opacity: 0.8,
        scroll: true,
        refreshPositions: true,
        scrollSensitivity: 100,
    });
});

【问题讨论】:

  • 你解决了吗?我遇到了类似的情况。
  • 嘿,对不起,我没有解决这个问题。我刚刚在左右两侧创建了 2 个 div 并触发了一个滚动事件。

标签: javascript jquery html css jquery-ui


【解决方案1】:

Flexbox 不是问题。 删除属性后,我成功拖动并使容器滚动: 助手:'克隆'

【讨论】:

    猜你喜欢
    • 2013-01-27
    • 2023-03-12
    • 2017-09-16
    • 2012-02-06
    • 2017-05-01
    • 1970-01-01
    • 2014-07-05
    • 2011-07-26
    • 1970-01-01
    相关资源
    最近更新 更多