简体   繁体   English

如何设置可拖动图像的宽度和高度?

[英]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');

} }

This is my jquery function to the drag image to the canvas. 这是我的jquery函数,用于将图像拖到画布上。 But when dragging the image it shows as its original image size. 但是,当拖动图像时,它将显示为原始图像大小。 How to define image size when dragging to the canvas. 拖动到画布时如何定义图像大小。

                start: function(event,ui) {
                $(this).css({ height: 100, width: 100 });
                },

                stop: function(event,ui) {
                $(this).css({ height: 100, width: 100 });
                },

You can try with above code. 您可以尝试使用上面的代码。 Otherwise simply you can set image size on your css file for .drag-image class. 否则,您可以简单地在css文件中为.drag-image类设置图像大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM