[英]How to set width and height to draggable image?
function login_callback() {
//alert("You are successfully logged in! Access Token: "+instaAccessToken);
var url = 'https://api.instagram.com/v1/users/self/media/recent/?access_token='+instaAccessToken;
$.get( url, function( data ) {
$.each(data.data, function(i, item) {
var thumb = item.images.low_resolution.url;
var image = item.images.standard_resolution.url;
var str = '<div class="col-xs-6"><img data-src="'+image+'" src="'+thumb+'" class="thumbnail drag-image"/></div>';
$('#instafeed').append(str);
$('.drag-image').draggable({
helper: 'clone',
appendTo: 'body',
containment: 'document',////
refreshPositions: true,
stop: function(event,ui) {
},
drag: function( event, ui ) {
handleDrag(event,ui);
}
});
});
},'jsonp');
}
這是我的jquery函數,用於將圖像拖到畫布上。 但是,當拖動圖像時,它將顯示為原始圖像大小。 拖動到畫布時如何定義圖像大小。
start: function(event,ui) {
$(this).css({ height: 100, width: 100 });
},
stop: function(event,ui) {
$(this).css({ height: 100, width: 100 });
},
您可以嘗試使用上面的代碼。 否則,您可以簡單地在css
文件中為.drag-image
類設置圖像大小。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.