Effortlessly manage image and video focus for modern, responsive layouts with NGX Focus Point. Whether your image needs to adapt to portrait, landscape, or square spaces, this Angular component ensures your subject always stays in the spotlight.
No more awkward clipping, misplaced subjects, or resizing issues. NGX Focus Point lets you define the perfect focal point for your media, giving you seamless results across all screen sizes and layouts. 🚀
VideoPositions
.time
from the parent component.debounceResizeUpdate
for performance optimization during resize.animationSpeed
.npm i @believablecreations/ngx-focus-point
yarn add @believablecreations/ngx-focus-point
Define video positions with an array of VideoPosition
:
export interface VideoPosition {
x: number;
y: number;
w?: number;
h?: number;
s?: number;
time: number;
}
export type VideoPositions = Array<VideoPosition>;
Example usage in a component:
<ngx-focus-point [focus]="[
{x: 0.5, y: 0.5, time: 0},
{x: 0.7, y: 0.3, s: 1.0, time: 5},
{x: 0.2, y: 0.8, time: 10}
]" [actions]="'play'" [time]="5" [debounceResizeUpdate]="50" [animationSpeed]="'500ms'">
<video autoplay loop>
<source src="your-video.mp4" />
</video>
</ngx-focus-point>
As of Angular 19, you can use standalone components. Just import the component and use it directly in your template:
import { Component } from '@angular/core';
import { NgxFocusPointComponent } from './ngx-focus-point.component';
@Component({
selector: 'app-root',
standalone: true,
imports: [NgxFocusPointComponent],
template: `
<ngx-focus-point [focusX]="0.0" [focusY]="0.0" [scale]="1">
<img src="your-image.jpg" alt="Sample Image" />
</ngx-focus-point>
`,
})
export class AppComponent {}
Define your focal point using focusX
and focusY
:
<ngx-focus-point [focusX]="0.0" [focusY]="0.0">
<img src="your-image.jpg" />
</ngx-focus-point>
<ngx-focus-point [focusX]="0.0" [focusY]="0.0">
<video autoplay loop muted="true" playsinline webkit-playsinline="true">
<source src="your-video.mp4" />
</video>
</ngx-focus-point>
Capture the focal point dynamically:
<ngx-focus-point-select (positionChange)="updateFocus($event)" src="your-image.jpg"></ngx-focus-point-select>
PositionModel Structure:
PositionModel {
x: number;
y: number;
w: number;
h: number;
s?: number;
}
Built with ❤️ by Believable Creations.