【问题标题】:Zooming an image on GWT on a certain spot在 GWT 上的某个位置缩放图像
【发布时间】:2019-06-04 11:00:22
【问题描述】:

有没有办法在某个位置放大 GWT 图像。就像在谷歌地图上一样。如果您滚动鼠标指针所在的部分,图像将放大该位置。 非常感谢!

【问题讨论】:

    标签: java gwt zooming gxt


    【解决方案1】:

    这可以解决问题。基于this JS response。完整源码here.

    EventType.bind(document, wheel, new EventCallbackFn<WheelEvent>() {
        double[] pos = {0, 0};
        double scale = 1;
        @Override
        public void onEvent(WheelEvent ev) {
            ev.preventDefault();
            // cap the delta to [-1,1] for cross browser consistency
            double delta = Math.max(-1, Math.min(1, ev.deltaY / 200.));
            // determine the point on where the img is zoomed in
            double[] zoomTarget = {(ev.pageX - pos[0]) / scale, (ev.pageY - pos[1]) / scale};
            // calculate zoom and x and y based on it
            scale = Math.max(.1, Math.min(10, scale + delta * scale));
            pos[0] = -zoomTarget[0] * scale + ev.pageX;
            pos[1] = -zoomTarget[1] * scale + ev.pageY;
            target.style.transform = "translate(" + pos[0] + "px ," + pos[1] + "px) scale(" + scale + ")";
        }
    });
    

    【讨论】:

    • 谢谢。我稍后会检查它! :)
    猜你喜欢
    • 2011-01-16
    • 2015-06-06
    • 1970-01-01
    • 2016-11-16
    • 2012-10-06
    • 2018-07-30
    • 2012-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多