- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想实现 react-native 拖放,以在放置时交换组件。假设屏幕上有五个组件,一旦我拖动它应该突出显示可放置的元素。一旦它被删除,组件应该被交换。
最佳答案
为了实现拖放,您需要使用平移响应器。首先,您需要定义对象移动时要将值存储在哪里,您可以在状态上设置一个属性。
state = {
pan: new Animated.ValueXY(),
};
然后您必须在 componentWillMount
中创建平移响应器,例如:
this.panResponder = PanResponder.create({
onStartShouldSetPanResponder : () => true,
onPanResponderMove : Animated.event([null,{ // <--- When moving
dx : this.state.pan.x,
dy : this.state.pan.y
}]),
onPanResponderRelease : (e, gesture) => {} // <--- callback when dropped
});
最后需要在render方法中给动画元素设置left和top。
<Animated.View
{...this.panResponder.panHandlers}
style={[this.state.pan.getLayout(), styles.circle]}>
<Text style={styles.text}>Drag me!</Text>
</Animated.View>
this.state.pan.getLayout()
返回顶部和左侧,您需要它来移动元素。
为了交换元素,您需要实现 onPanResponderRelease
。
更多详细步骤可以看教程:https://moduscreate.com/blog/animated_drag_and_drop_with_react_native
关于react-native - 如何实现,React Native Drag-n-Drop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48443324/
我正在尝试使Polymer Dart元素可拖动,并与列表中的另一个项目交换信息。我最近的尝试是使用元素。我正在使用由trackstart,track和trackend的此元素创建的事件。我可以触发它们
我正在使用 Windows 窗体在 C# 中构建桌面应用程序。我有一个自定义控件,我希望能够将它拖放到我的应用程序中(而不是外部)。现在我正在使用通常的 DoDragDrop/OnDragOver/O
我有一个#topleft红色标题栏,其中包含多个“选项卡”按钮,这些按钮应填充除#topright蓝色块之外的所有可用空间。 在#topleft的红色背景上单击并拖动,可以移动 Electron 主窗
我希望能够移动(在灰色背景上,通过拖放)Bootstrap 2 提供的模态表单。谁能告诉我实现此目的的最佳实践是什么? 最佳答案 默认情况下, Bootstrap 不附带任何拖放功能,但您可以添加一些
我只想在屏幕上拖动小部件,而不是拖放。 但是,每当我离开它并再次开始拖动时,它就会从开始的位置开始被拖动。就好像它被重置了。 我的猜测是构建被一次又一次地调用,所以它自动使用原始位置值。我该如何解决?
我只想在屏幕上拖动小部件,而不是拖放。 但是,每当我离开它并再次开始拖动时,它就会从开始的位置开始被拖动。就好像它被重置了。 我的猜测是构建被一次又一次地调用,所以它自动使用原始位置值。我该如何解决?
我试图在拖放过程中更改节点上的光标,但图像没有改变。我打电话 setCursor()在 DragDetectedEventHandler我的节点。我也试过调用 getParent().setCurso
这个问题已经有答案了: D3.js: Remove force.drag from a selection (3 个回答) 已关闭 7 年前。 我将以下内容附加到 svg 元素 var dragger
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
使用 jsTree 3.0.8 我想允许在树中拖放节点,但它应该只允许通过拖动特定按钮或“拖动 handle ”而不是默认的操作来启动该操作允许拖动行上任意位置的行为。 我通过 Html 填充我的树,
当元素开始被拖动时,我需要修改它。 “开始”回调有两个参数,只有第一个参数对我有用。交易是我正在使用 helper: 'clone' 这使得 event.originalTarget 仅指向“原始”元
我有一个可拖动的 img 元素。现在我想手动触发 drag() 事件,就像我们如何触发 'click' 事件一样 $(element).trigger('click')。谢谢。 这是我的函数定义 $(
这是我的 jsfiddle 代码: http://jsfiddle.net/SMqR9/16/ 您会注意到,在 IE7 中,当您向上拖动一个元素时,它在放置之前一直可见。但是,如果您向下拖动一个元素,
我是 knockout JavaScript 的新手。在我的元素中,我使用了 Knockout 拖放功能。最初我有两个部门,一个是可见的,另一个没有属性显示。当我执行拖动输入功能时,我需要隐藏第一个分
上下文:如下面jsp内输入框中的代码所示,要拖放“fruitTree”中的水果节点。 这在拖放时成功发生。每次我从fruitTree中拖放水果时,先前拖放的水果节点都会被新拖放的水果覆盖。 问题:现在
我想移动一定距离。但是,在我的系统中,存在惯性/拖动/负加速度。我正在使用这样的简单计算: v = oldV + ((targetV - oldV) * inertia) 将其应用于多个帧会使运动“上
我正在使用 Kendo Grid UI。下面是一个相同的例子。 Grid / Column resizing
我有这个页面,我只能在浏览器中访问。有一个HTML元素仅在拖放过程中存在,并且我想在Inspector / Firebug中获取/分析其HTML代码。但是一旦我停止拖动,该元素就会被删除。 有什么方法
这真杀了我。我不小心将文件拖到其他位置时遇到问题。与其他编辑器相比,在vscode中,我似乎更经常为此受害。是否有任何插件,设置或其他使我无法使用鼠标技能的东西? 最佳答案 我有同样的问题。当文件夹意
//The following game has been designed as an educational resource //for Key Stage 1 and 2 children.
我是一名优秀的程序员,十分优秀!