You are not logged in.

Dear visitor, welcome to Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Wednesday, January 23rd 2019, 7:36pm

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


This post has been edited 1 times, last edit by "bhh" (Jan 23rd 2019, 8:28pm)



Posts: 311

Occupation: coding in krpano

  • Send private message


Thursday, January 24th 2019, 11:03am

Hi, I shared on the forum option where the zoom is at the cursor location

Download the archive and there is an example with the code


Thursday, January 24th 2019, 4:47pm

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*

This post has been edited 1 times, last edit by "bhh" (Jan 24th 2019, 5:42pm)


Thursday, January 24th 2019, 9:20pm

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.

This post has been edited 1 times, last edit by "bhh" (Jan 24th 2019, 9:33pm)


Thursday, January 24th 2019, 9:50pm

Hi bhh, San7,

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

Source code

<control zoomtocursor="true" zoomoutcursor="true" />
in the tour.xml (after the <skin_settings>).

Does it help you?



Thursday, January 24th 2019, 10:54pm

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!