我有几个用户应该能够拖放的UIViews.我使用UIPanGestureRecognizer来管理d&d操作(参见下面的代码).d&d动作工作正常,但当我开始拖动另一个UIView时,我刚刚放弃的那个跳回原来的位置.
- (void)handlePan:(UIPanGestureRecognizer *)recognizer {
CGPoint translation = [recognizer translationInView:self.view];
switch (recognizer.state) {
case UIGestureRecognizerStateBegan:
for (UIView* checkView in dragAndDropImageViewsArray) {
if (checkView == recognizer.view) {
[checkView.superview bringSubviewToFront:checkView]; //this is done to make sure the currently dragged object is the top one
}
}
break;
case UIGestureRecognizerStateChanged:
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y + translation.y);
break;
case UIGestureRecognizerStateEnded:
NSLog(@"UIGestureRecognizerStateEnded");
break;
default:
break;
}
[recognizer setTranslation:CGPointMake(0, 0) inView:self.view];
}
Run Code Online (Sandbox Code Playgroud)
我尝试了几个"解决"问题但引起其他问题的事情:
我开始加深对Auto Layout的理解,但是在我看来,我正在寻找的东西应该非常简单; 我看到很多方法都涉及执行"重新自动布局",但我不清楚如何使用它们.
这里有简单的解决方案吗?比如调用一个覆盖IB Auto-Layout约束的方法并根据UIView的新位置重新定义它们? …
我有这个代码:
function drop(evt) {
evt.stopPropagation();
evt.preventDefault();
var imageUrl = evt.dataTransfer.getData('URL');
alert(imageUrl);
}
Run Code Online (Sandbox Code Playgroud)
如果删除<img>元素,它会提醒图像的URL.到现在为止还挺好.
我的问题是,如果你删除的<a>元素它会提醒的网址href的<a>元素.如果您在上面的示例中下载图像,我想提醒<img>内部元素的url <a>.
那可能吗?
我不介意使用Jquery或任何其他库.我只想把图像的url放在一个<a>元素中.
重点是将图像链接从其他网站拖到我的网站并获取图像的网址.
为了更清楚我想要实现的目标,请尝试在此帖子下拖动我的个人资料图片并将其放入小提琴中.它提醒http://stackoverflow.com/users/3074592/laaposto.我想http://i.stack.imgur.com/juvdV.jpg?s=32&g=1收到提醒.
我希望该解决方案适用于最新版本的Chrome和Firefox.
我试图在https://github.com/desandro/draggabilly上使用draggabilly
它在html中工作正常.现在,当我试图在wordpress中添加它.我在firebug控制台中遇到以下错误.
TypeError: Argument 1 of Window.getComputedStyle is not an object.
return s.getComputedStyle(t, null)
Run Code Online (Sandbox Code Playgroud)
这是js文件的链接 http://draggabilly.desandro.com/draggabilly.pkgd.min.js
我想创建一个div附加拖放功能,当有人点击它时,他们可以选择他们的图像.
我编写了一些东西,它可以 - 点击div并选择你的图像 - 在上传之前预览你的图像
你可以检查我的小提琴
CSS
.uploader {width:300px;height:350px;background:#f3f3f3;border:2px dashed #e8e8e8;}
Run Code Online (Sandbox Code Playgroud)
JavaScript的
var imageLoader = document.getElementById('filePhoto');
imageLoader.addEventListener('change', handleImage, false);
function handleImage(e) {
var reader = new FileReader();
reader.onload = function (event) {
$('.uploader').html( '<img width="300px" height="350px" src="'+event.target.result+'"/>' );
}
reader.readAsDataURL(e.target.files[0]);
}
Run Code Online (Sandbox Code Playgroud)
HTML
<div class="uploader" onclick="$('#filePhoto').click()">click here or drag here your images for preview and set userprofile_picture data</div>
<input type="file" name="userprofile_picture" id="filePhoto" style="display:block;width:185px;" />
Run Code Online (Sandbox Code Playgroud)
我正在开发一个Android应用程序,它RecyclerView包含LinearLayout一个自定义项目列表.如何使用拖放功能订购这些物品?
monitor.getDropResult()返回null(我看它是console.log).它应该返回对象(拖动项)及其位置.为什么它返回null?
我使用DragSource,DropTarget对我的组件进行签名.但它仍然返回null
这是我的整个组件代码:
import React, { PropTypes } from 'react';
import { DragSource } from 'react-dnd';
import { getEmptyImage } from 'react-dnd-html5-backend';
import { StoneConstants, StoneTypes, ItemTypes } from 'constants/AppConstants';
import OkeyStoneBase from 'components/OkeyStoneBase/OkeyStoneBase';
import './_OkeyStone.scss';
function checkForDragAction(props) {
// TODO receive the action via prop
if (props.stoneType === StoneTypes.ON_WITHDRAW_MIDDLE) {
props.onWithdrawMiddle();
} else if (props.stoneType === StoneTypes.ON_DISCARD_WEST) {
props.onWithdrawLeft();
}
}
function applyDropResult(props, result) {
if (props.stoneType === StoneTypes.ON_WITHDRAW_MIDDLE || props.stoneType === StoneTypes.ON_DISCARD_WEST) {
if (result === null) …Run Code Online (Sandbox Code Playgroud) 迁移到Swift4后,以下代码引发编译错误:
public final class MediaItemView: NSView {
public override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
// error: 'NSFilenamesPboardType' is unavailable in Swift:
// use 'NSPasteboard.writeObjects(_:)' with file URLs
let draggedTypes: [NSPasteboard.PasteboardType] = [NSFilenamesPboardType]
registerForDraggedTypes(draggedTypes)
}
}
Run Code Online (Sandbox Code Playgroud)
什么是NSFilenamesPboardTypeSwift4 的替代品?如何file name在Swift4中注册拖动类型(在我的情况下是mp3,wav,aiff,...文件)?
谢谢!
这是关于"cdk dnd"和"嵌套"的第三个问题!
我没有得到另一个SO问题的hacky建议.
所以这里有一个非常简单的基础- > STACKBLITZ < -我创造了.一切正常,我与容器内的嵌套元素进行交互.
当我尝试仅对嵌套元素进行排序时,angular会尝试使用容器本身对嵌套元素进行排序...这会产生不需要的行为.
有谁知道如何解决这个问题?明天我会继续这个工作.
我正在玩 cdk 拖放,因为我需要它来创建工作的 POC。我从文档网站上的这段代码开始。我看到每次我将一个元素拖到它的列表之外时,该元素都会被隐藏,直到我把它放到同一个列表或另一个列表中。
所以告诉我如果我错了,但似乎被拖动的元素不是列表项的副本,而是元素本身。
总之,我希望列表在拖动其中一个元素时不更改其布局。
长话短说:
我在 cdk 文档中没有找到任何可以执行此操作的内容。
我正在尝试创建一个满足以下条件的 ListView:
如果ReorderableListView允许您禁用 ListTile 被拖放(换句话说,我将能够在 ListView 中将标题创建为 ListTile 项,并仅禁用它们的拖放,同时仍然允许其他所有内容),那么这将很容易实现被拖放),但我不知道如何。有小费吗?
drag-and-drop ×10
javascript ×4
jquery ×3
angular ×2
android ×1
angular-cdk ×1
autolayout ×1
cocoa ×1
flutter ×1
image ×1
ios ×1
jquery-ui ×1
listview ×1
macos ×1
php ×1
react-dnd ×1
reactjs ×1
reorderlist ×1
sorting ×1
subviews ×1
swift ×1
swift4 ×1
url ×1