Custom layer alignments?

  • I've implemented a touch zoomable and touch panable layer (floorplan) via a combination of the scroll area plugin and the mouse zoom hijack trick Klaus illustrated in this thread...
    https://krpano.com/forum/wbb/inde…touch#post72147


    It works great and has a very native OS feel with the exception that zoom events take place around the layer alignment rather than the cursor/touch location.

    My idea for a solution is to track the cursor/touch locations of that layer and just offset the alignment point to that location. That is proving impossible though since the only alignment options we have are lefttop, left, leftbottom, top, center, bottom, righttop, right, rightbottom. Am I missing something here or is there another work around anyone can think of? Is it possible to offset an alignment point to a custom value? Control.zoomtocursor works for the pano but seems to have no affect on other layers.


    Thanks.

    Edited once, last by bhh (January 23, 2019 at 8:28 PM).

  • Thanks San7. Not sure how I missed that the first time around! I see what you are doing, pretty clever. When I first tested, It was only working with the mouse zoom and not with touch but I see why when I looked at your xml file. I'm going to spend some time today working on this and and see what I can come up with along the lines of what you are doing.

    My application is a little different because my image file is nested in a "scroll area" plugin layer so my "image_onmousewheel" action is scaling up my scroll area layer rather than the image. What I tried last night was converting the touch points to layer coordinates via screentolayer() and then using the scrollarea.setcenter() to shift the image center to the touch point when scaling up. It wasn't working great and was jerky but that also has some promise (I think it is bouncing back and forth between the touchpoints of both fingers currently).

    Thanks for responding. Much appreciated.

    EDIT: I've dug more into your "align_delta" function. Wow, very impressive! I'm hoping I have the brainpower to integrate this into my use case but great job *thumbsup*

    Edited once, last by bhh (January 24, 2019 at 5:42 PM).

  • Also, Is the Scroll Area plugin's update() function broken? Seems to be triggering a WARNING: Unknown action error.
    EDIT: updatepos() seems to be working.

    Edited once, last by bhh (January 24, 2019 at 9:33 PM).

  • Hi bhh, San7,

    Sorry for not sharing my findings, but maybe you will be supprised by this simple solution. Just use this

    Code
    <control zoomtocursor="true" zoomoutcursor="true" />

    in the tour.xml (after the <skin_settings>).

    Does it help you?

    Pavel

  • Pur,
    Thanks for posting. That works zooming in on a pano image but it has no affect for me on a regular image layer. Perhaps I'm missing something?
    There may be an easier way but San7's solution I think is going to work in theory, I'm just having to reverse engineer how to apply that concept to recentering a scroll area since my zooms are just scaling up scroll area inside of a fixed window. It is making my head hurt but I think I will eventually work it out!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!