Skip to content

Commit

Permalink
Removed scrollParentSelector and isInsideStaticContainer inputs that …
Browse files Browse the repository at this point in the history
…are no longer used with new calculations.

Wrote changelog.
  • Loading branch information
wittlock committed Feb 26, 2020
1 parent 1bdc0db commit 721e2ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="0.6.0"></a>
# 0.6.0

### Breaking changes
* Removed input parameters *scrollParentSelector* and *isInsideStaticContainer* as I believe these are no longer needed.

### Features
* Rewrote the zooming position calculations, it feels much more robust now and will hopefully perform as expected in
more situations with complex layouts.

<a name="0.5.1"></a>
# 0.5.1

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ lensHeight | 100 | Height of the lens, if enabled.
circularLens | false | Make the lens circular instead of square. This will only look good if width and height are equal.
minZoomRatio | *baseRatio* | Lower limit on how much zoom can be applied with scrollZoom enabled. See below for details.
maxZoomRatio | 2 | Upper limit on how much zoom can be applied with scrollZoom enabled. See below for details.
scrollParentSelector | *none* | Selector of parent scrolling view as string. This avoid zoom gap with cursor when the scrolling view is not the main window. Example : `#scrolling-frame`
isInsideStaticContainer | false | Set to `true` if the thumbnail is inside a container, to which `position: static` is applied (e.g. a modal window). This is required to avoid zoom position being calculated incorrectly.

### Zoom modes
Mode | Description
Expand Down
25 changes: 3 additions & 22 deletions src/lib/ngx-image-zoom.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, Renderer2, ViewChild } from '@angular/core';
import { Component, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, Renderer2, ViewChild } from '@angular/core';

export interface Coord {
x: number;
Expand All @@ -10,7 +10,7 @@ export interface Coord {
templateUrl: './ngx-image-zoom.component.html',
styleUrls: ['./ngx-image-zoom.component.css']
})
export class NgxImageZoomComponent implements OnInit, OnChanges, AfterViewInit, OnDestroy {
export class NgxImageZoomComponent implements OnInit, OnChanges, OnDestroy {

private static readonly validZoomModes: string[] = ['hover', 'toggle', 'click', 'hover-freeze'];

Expand Down Expand Up @@ -61,13 +61,10 @@ export class NgxImageZoomComponent implements OnInit, OnChanges, AfterViewInit,

private latestMouseLeft: number;
private latestMouseTop: number;
private scrollParent: Element;
private scrollParentSelector: string;
private isInsideStaticContainer = false;

private eventListeners: (() => void)[] = [];

constructor(private renderer: Renderer2, private elRef: ElementRef) {
constructor(private renderer: Renderer2) {
}

@Input('thumbImage')
Expand Down Expand Up @@ -138,16 +135,6 @@ export class NgxImageZoomComponent implements OnInit, OnChanges, AfterViewInit,
this.enableScrollZoom = Boolean(enable);
}

@Input('scrollParentSelector')
public set setScrollParentSelector(selector: string) {
this.scrollParentSelector = selector;
}

@Input('isInsideStaticContainer')
public set setisInsideStaticContainer(isInStatic: boolean) {
this.isInsideStaticContainer = isInStatic;
}

ngOnInit(): void {
this.setUpEventListeners();
}
Expand All @@ -164,12 +151,6 @@ export class NgxImageZoomComponent implements OnInit, OnChanges, AfterViewInit,
this.calculateImageAndLensPosition();
}

ngAfterViewInit(): void {
this.scrollParent = this.scrollParentSelector ?
document.querySelector(this.scrollParentSelector) :
this.elRef.nativeElement.parentElement;
}

ngOnDestroy(): void {
this.eventListeners.forEach((destroyFn) => destroyFn());
}
Expand Down

0 comments on commit 721e2ba

Please sign in to comment.