Skip to content

Lens background location is not exact #18

Description

@TalR98

There are mistakes in both zoomX and in zoomY.

Current:
zoomX = -Math.floor(relX / $element.width() * (NATIVE_IMG.width * $options.scale) - $options.width / 2);
zoomY = -Math.floor(relY / $element.height() * (NATIVE_IMG.height * $options.scale) - $options.height / 2);

In this mistake state, this is wrong (even in the demo):
image

While cursor is in the edge of the photo, the lens position has mistake - you can see the cursor position is not on the edge in the zoom, although it was on edge in the photo).

The fix:
zoomX =-6 -Math.floor(relX / $element.width() * (NATIVE_IMG.width * $options.scale) - $options.width / 2);
zoomY =-6 -Math.floor(relY / $element.height() * (NATIVE_IMG.height * $options.scale) - $options.height / 2);
(Just added -6 to each calculation)

Don't really know why tho (LOL) but it works now for every image..

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions