简体   繁体   中英

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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