jQuery如何仅在Y轴上拖动按钮

时间:2019-02-11 07:54:10

标签: javascript jquery html

我在右侧有一个定位的绝对按钮,我想仅通过Y轴拖动该按钮。如何通过jQuery而不使用任何第三方插件来完成此操作?

JS Fiddle

    <div id="feedback-modal" class="feedback-modal"><div class="modal fade" id="feedbackModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
</div>

<div class="right-button-wrapper">
    <div class="feedback-button" style="transform: translate(0px, 0px);">
        <button class="btn btn-primary btn-feedback" id="feedback-form">Draggable Button</button>
    </div>
</div>
</div>

CSS

.right-button-wrapper {
    position: absolute;
    z-index: 1100;
    right: -61px;
    top: 45%;
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    transform: rotate(-90deg);
}

.right-button-wrapper .feedback-button {
    transform: translate(0px, 0px);
    -webkit-transition: .3s ease;
    -moz-transition: .3s ease;
    -o-transition: .3s ease;
    transition: .3s ease;
}

0 个答案:

没有答案