BrowseLens

Effects

Glass Lens

A magnifying bead you drag around; its rim bends whatever lies beneath.

Preview

A closer look at the details.

Installation

Install the package once, then import the parts you use into a standalone component.

Install

npm install ngx-vitreo @angular/cdk @floating-ui/dom
Import

import { GlassLens } from 'ngx-vitreo';

@Component({
  imports: [GlassLens],
  // ...
})

Usage

Usage

<glass-lens [size]="116" [zoom]="1.7" [defaultPosition]="{ x: 0.62, y: 0.5 }">
  <ng-template>
    <div class="my-artwork">A closer look at the details.</div>
  </ng-template>
</glass-lens>

API reference

GlassLens

glass-lens

InputTypeDefaultDescription
<ng-template>TemplateRefNoneContent to magnify, as a child template. It renders twice, so give it its own background and avoid ids.
sizenumber160Lens diameter in pixels.
zoomnumber1.6Magnification inside the lens.
defaultPosition{ x: number; y: number }{ x: 0.5, y: 0.5 }Starting centre as fractions of the stage's width and height.
labelstring'Magnifier'Accessible name of the lens.
driftbooleanfalseMoves the lens on its own: over text it reads along each line in turn and back; over anything else it glides across. It waits while held and drifts on after. Reduced motion keeps it still.
driftDurationnumber7000Milliseconds the drifting lens takes to cross the stage's width.
decorativebooleanfalseFor a lens that only shows off what it passes over, as on a heading: hidden from assistive technology and out of the tab order, and kept wholly on the stage so nothing is cut off.