我如何让“Facebook Zoom”变成“Facebook 缩放”?

发布于 2024-10-21 09:41:59 字数 434 浏览 7 评论 0原文

我正在制作一个网站,我喜欢这个 google chrome 扩展调用 Facebook Photo Zoom @ https:/ /chrome.google.com/extensions/detail/elioihkkcdgakfbahdoddophfngopipi

我认为该扩展背后的基本思想是,当您将鼠标悬停在缩略图上时,它会抓取原始图像文件并以完整视图显示它。如果图像太大,那么它将位于窗口的角落或顶部和底部栏上。如果不是太大,它会漂浮在鼠标位置旁边。

我理解其背后的逻辑,但实际编码似乎有点令人畏惧。我想我唯一不明白的部分是如何对扩展图像的位置进行编码,并在将鼠标向左/右移动时使它们收缩/扩展。谢谢

Im making a website, and i love the functionality of this google chrome extension call Facebook Photo Zoom @ https://chrome.google.com/extensions/detail/elioihkkcdgakfbahdoddophfngopipi

I think the essential idea behind the extension is when you hover over the thumbnail, it grabs the original image file and displays it in full view. If the image is too big, then it will be position on the corners or the top and bottom bars of the window. If it is not too big, it will float next to the mouse position.

The logic behind it i understand, but the actually coding seems to be a bit daunting. I guess the only parts of it i dont understand is how do you code the positions of the expanded images and make them contract/expand when you move your mouse to the left/right. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

怀念你的温柔 2024-10-28 09:41:59

这里有 13 个缩放 jquery 插件。选择最适合您需求的:)

13 zoom jquery plugins in here. Choose the best for your needs:)

情仇皆在手 2024-10-28 09:41:59

创建大图像

css({position: 'absolute', left: e.pageX, top: e.pageY})

鼠标悬停 上,您可以在 mousemove 您以相同的方式更新左侧和顶部。

另请检查:

on mouseover you create big image with

css({position: 'absolute', left: e.pageX, top: e.pageY})

on mousemove you update the left and top in the same way.

check also:

毁我热情 2024-10-28 09:41:59

查看这个预览图像工具提示,它与 Chrome 扩展程序的功能类似,但您必须向其提供缩略图和全尺寸图像的 URL。这是原始的博客文章


我修改了脚本以调整图像大小以适合光标和浏览器右边缘之间的距离。它并不完美,但它有效。这是一个演示

/*
 * Image preview script
 * powered by jQuery (http://www.jquery.com)
 *
 * written by Alen Grakalic (http://cssglobe.com)
 *
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */

this.imagePreview = function(){
    /* CONFIG */

        xOffset = 10;
        yOffset = 20;

        // these 2 variable determine popup's distance from the cursor
        // you might want to adjust to get the right result

    /* END CONFIG */
    $('a.preview').hover(function(e){
        this.t = this.title;
        this.title = '';
        var p, c = (this.t != '') ? '<br/>' + this.t : '';
        $('body').append('<p id="preview"><img src="' + this.href + '" alt="Image preview" />' + c + '</p>');

        // load image and get size
        p = $('#preview');
        p
            .fadeIn('fast')
            .find('img').load(function(){
                // get image dimensions after it has been loaded
                p.data('widths', [ $(window).width(), p.find('img').width() ]);
                // set image to 100% to fit in preview window
                $(this).width('100%');
                position(e);
            });
    },
    function(){
        this.title = this.t;
        $('#preview').remove();
    });

    $('a.preview').mousemove(function(e){
        position(e);
    });

    var position = function(e){
        var w, prevw = $('#preview'),
            w = $.data( prevw[0], 'widths' );
        if ( w ) {
            prevw
                .css('top', e.pageY + yOffset)
                .css('left', e.pageX + xOffset)
                .css('max-width', (e.pageX + prevw.outerWidth() > w[0]) ?  w[0] - e.pageX - xOffset : w[1] || 'auto' );
        }
    };

};

// starting the script on page load
$(document).ready(function(){
    imagePreview();
});

Check out this preview image tooltip which is similar to what that Chrome extension does, but you have to provide it the url to the thumbnail and full sized image. Here is the original blog post.


I modified the script to adjust the image size to fit the distance between the cursor and right browser edge. It's not perfect, but it works. Here is a demo.

/*
 * Image preview script
 * powered by jQuery (http://www.jquery.com)
 *
 * written by Alen Grakalic (http://cssglobe.com)
 *
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */

this.imagePreview = function(){
    /* CONFIG */

        xOffset = 10;
        yOffset = 20;

        // these 2 variable determine popup's distance from the cursor
        // you might want to adjust to get the right result

    /* END CONFIG */
    $('a.preview').hover(function(e){
        this.t = this.title;
        this.title = '';
        var p, c = (this.t != '') ? '<br/>' + this.t : '';
        $('body').append('<p id="preview"><img src="' + this.href + '" alt="Image preview" />' + c + '</p>');

        // load image and get size
        p = $('#preview');
        p
            .fadeIn('fast')
            .find('img').load(function(){
                // get image dimensions after it has been loaded
                p.data('widths', [ $(window).width(), p.find('img').width() ]);
                // set image to 100% to fit in preview window
                $(this).width('100%');
                position(e);
            });
    },
    function(){
        this.title = this.t;
        $('#preview').remove();
    });

    $('a.preview').mousemove(function(e){
        position(e);
    });

    var position = function(e){
        var w, prevw = $('#preview'),
            w = $.data( prevw[0], 'widths' );
        if ( w ) {
            prevw
                .css('top', e.pageY + yOffset)
                .css('left', e.pageX + xOffset)
                .css('max-width', (e.pageX + prevw.outerWidth() > w[0]) ?  w[0] - e.pageX - xOffset : w[1] || 'auto' );
        }
    };

};

// starting the script on page load
$(document).ready(function(){
    imagePreview();
});
如痴如狂 2024-10-28 09:41:59

请参阅 Kabbar 图像缩放器 http://www.ideabonus.com/Kabbar/index.html

See the Kabbar Image Zoomer at http://www.ideabonus.com/Kabbar/index.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文