@jojovms/angular-tilt-card 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @jojovms/angular-tilt-card
2
+
3
+ Angular directive for the Tilt Card library.
4
+
5
+ ## Installation
6
+ ```bash
7
+ npm install @jojovms/angular-tilt-card
8
+ ```
9
+
10
+ ## Setup
11
+ Import `TiltModule` in your `app.module.ts`.
12
+
13
+ ## Usage
14
+ ```html
15
+ <div [tilt]="{ max: 20, glare: true }">
16
+ <h1>Hover Me</h1>
17
+ </div>
18
+ ```
@@ -0,0 +1,3 @@
1
+ export * from './tilt.directive';
2
+ export * from './tilt.module';
3
+ export type { TiltOptions } from '@jojovms/tilt-card-core';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@angular/core");var f=Object.defineProperty,E=(i,e,n)=>e in i?f(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,r=(i,e,n)=>E(i,typeof e!="symbol"?e+"":e,n);class b{constructor(e,n={}){r(this,"element"),r(this,"options"),r(this,"glareElement",null),r(this,"bounds",null),r(this,"onMouseEnter",()=>{var t;this.bounds=this.element.getBoundingClientRect(),this.element.style.transition="none",(t=this.glareElement)!=null&&t.firstChild&&(this.glareElement.firstChild.style.transition="opacity 100ms")}),r(this,"onMouseMove",t=>{var s;if(!this.bounds)return;const l=t.clientX-this.bounds.left,o=t.clientY-this.bounds.top,h=l/this.bounds.width,m=o/this.bounds.height,p=this.options.max||15,u=(.5-m)*p*2,v=(h-.5)*p*2;if(this.element.style.transform=`
2
+ perspective(${this.options.perspective}px)
3
+ rotateX(${u}deg)
4
+ rotateY(${v}deg)
5
+ scale3d(${this.options.scale}, ${this.options.scale}, ${this.options.scale})
6
+ `,this.options.glare&&(s=this.glareElement)!=null&&s.firstChild){const c=this.glareElement.firstChild,g=Math.atan2(t.clientX-(this.bounds.left+this.bounds.width/2),-(t.clientY-(this.bounds.top+this.bounds.height/2)))*(180/Math.PI),y=Math.sqrt(Math.pow(h-.5,2)+Math.pow(m-.5,2))*2;c.style.transform=`translate(-50%, -50%) rotate(${g}deg)`,c.style.opacity=(y*(this.options.glareMaxOpacity||.5)).toString()}}),r(this,"onMouseLeave",()=>{var t;if(this.element.style.transition="transform 300ms ease-out",this.element.style.transform=`perspective(${this.options.perspective}px) rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)`,this.options.glare&&(t=this.glareElement)!=null&&t.firstChild){const s=this.glareElement.firstChild;s.style.opacity="0",s.style.transition="opacity 300ms"}}),this.element=typeof e=="string"?document.querySelector(e):e,this.options={max:15,perspective:1e3,scale:1.05,glare:!1,glareMaxOpacity:.5,...n},this.element&&this.init()}init(){this.element.style.transformStyle="preserve-3d",this.element.style.transform=`perspective(${this.options.perspective}px)`,this.options.glare&&this.addGlare(),this.element.addEventListener("mouseenter",this.onMouseEnter),this.element.addEventListener("mousemove",this.onMouseMove),this.element.addEventListener("mouseleave",this.onMouseLeave)}addGlare(){this.glareElement=document.createElement("div"),this.glareElement.style.position="absolute",this.glareElement.style.top="0",this.glareElement.style.left="0",this.glareElement.style.width="100%",this.glareElement.style.height="100%",this.glareElement.style.overflow="hidden",this.glareElement.style.pointerEvents="none",this.glareElement.style.borderRadius=getComputedStyle(this.element).borderRadius;const e=document.createElement("div");e.style.position="absolute",e.style.top="50%",e.style.left="50%",e.style.pointerEvents="none",e.style.backgroundImage="linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%)",e.style.width="200%",e.style.height="200%",e.style.transform="translate(-50%, -50%) rotate(0deg)",e.style.opacity="0",e.style.transition="opacity 300ms",this.glareElement.appendChild(e),this.element.appendChild(this.glareElement)}destroy(){this.element.removeEventListener("mouseenter",this.onMouseEnter),this.element.removeEventListener("mousemove",this.onMouseMove),this.element.removeEventListener("mouseleave",this.onMouseLeave),this.glareElement&&this.glareElement.remove()}}var M=Object.defineProperty,T=Object.getOwnPropertyDescriptor,d=(i,e,n,t)=>{for(var s=t>1?void 0:t?T(e,n):e,l=i.length-1,o;l>=0;l--)(o=i[l])&&(s=(t?o(e,n,s):o(s))||s);return t&&s&&M(e,n,s),s};exports.TiltDirective=class{constructor(e){this.el=e,this.options={},this.tiltInstance=null}ngOnInit(){this.initTilt()}ngOnChanges(e){this.tiltInstance&&(this.tiltInstance.destroy(),this.initTilt())}initTilt(){this.tiltInstance=new b(this.el.nativeElement,this.options)}ngOnDestroy(){this.tiltInstance&&this.tiltInstance.destroy()}};d([a.Input("tilt")],exports.TiltDirective.prototype,"options",2);exports.TiltDirective=d([a.Directive({selector:"[tilt]"})],exports.TiltDirective);var O=Object.getOwnPropertyDescriptor,w=(i,e,n,t)=>{for(var s=t>1?void 0:t?O(e,n):e,l=i.length-1,o;l>=0;l--)(o=i[l])&&(s=o(s)||s);return s};exports.TiltModule=class{};exports.TiltModule=w([a.NgModule({declarations:[exports.TiltDirective],exports:[exports.TiltDirective]})],exports.TiltModule);
package/dist/index.mjs ADDED
@@ -0,0 +1,94 @@
1
+ import { Input as E, Directive as b, NgModule as M } from "@angular/core";
2
+ var w = Object.defineProperty, C = (i, e, n) => e in i ? w(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, r = (i, e, n) => C(i, typeof e != "symbol" ? e + "" : e, n);
3
+ class O {
4
+ constructor(e, n = {}) {
5
+ r(this, "element"), r(this, "options"), r(this, "glareElement", null), r(this, "bounds", null), r(this, "onMouseEnter", () => {
6
+ var t;
7
+ this.bounds = this.element.getBoundingClientRect(), this.element.style.transition = "none", (t = this.glareElement) != null && t.firstChild && (this.glareElement.firstChild.style.transition = "opacity 100ms");
8
+ }), r(this, "onMouseMove", (t) => {
9
+ var s;
10
+ if (!this.bounds) return;
11
+ const l = t.clientX - this.bounds.left, o = t.clientY - this.bounds.top, h = l / this.bounds.width, m = o / this.bounds.height, p = this.options.max || 15, g = (0.5 - m) * p * 2, v = (h - 0.5) * p * 2;
12
+ if (this.element.style.transform = `
13
+ perspective(${this.options.perspective}px)
14
+ rotateX(${g}deg)
15
+ rotateY(${v}deg)
16
+ scale3d(${this.options.scale}, ${this.options.scale}, ${this.options.scale})
17
+ `, this.options.glare && (s = this.glareElement) != null && s.firstChild) {
18
+ const d = this.glareElement.firstChild, y = Math.atan2(t.clientX - (this.bounds.left + this.bounds.width / 2), -(t.clientY - (this.bounds.top + this.bounds.height / 2))) * (180 / Math.PI), f = Math.sqrt(Math.pow(h - 0.5, 2) + Math.pow(m - 0.5, 2)) * 2;
19
+ d.style.transform = `translate(-50%, -50%) rotate(${y}deg)`, d.style.opacity = (f * (this.options.glareMaxOpacity || 0.5)).toString();
20
+ }
21
+ }), r(this, "onMouseLeave", () => {
22
+ var t;
23
+ if (this.element.style.transition = "transform 300ms ease-out", this.element.style.transform = `perspective(${this.options.perspective}px) rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)`, this.options.glare && (t = this.glareElement) != null && t.firstChild) {
24
+ const s = this.glareElement.firstChild;
25
+ s.style.opacity = "0", s.style.transition = "opacity 300ms";
26
+ }
27
+ }), this.element = typeof e == "string" ? document.querySelector(e) : e, this.options = {
28
+ max: 15,
29
+ perspective: 1e3,
30
+ scale: 1.05,
31
+ glare: !1,
32
+ glareMaxOpacity: 0.5,
33
+ ...n
34
+ }, this.element && this.init();
35
+ }
36
+ init() {
37
+ this.element.style.transformStyle = "preserve-3d", this.element.style.transform = `perspective(${this.options.perspective}px)`, this.options.glare && this.addGlare(), this.element.addEventListener("mouseenter", this.onMouseEnter), this.element.addEventListener("mousemove", this.onMouseMove), this.element.addEventListener("mouseleave", this.onMouseLeave);
38
+ }
39
+ addGlare() {
40
+ this.glareElement = document.createElement("div"), this.glareElement.style.position = "absolute", this.glareElement.style.top = "0", this.glareElement.style.left = "0", this.glareElement.style.width = "100%", this.glareElement.style.height = "100%", this.glareElement.style.overflow = "hidden", this.glareElement.style.pointerEvents = "none", this.glareElement.style.borderRadius = getComputedStyle(this.element).borderRadius;
41
+ const e = document.createElement("div");
42
+ e.style.position = "absolute", e.style.top = "50%", e.style.left = "50%", e.style.pointerEvents = "none", e.style.backgroundImage = "linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%)", e.style.width = "200%", e.style.height = "200%", e.style.transform = "translate(-50%, -50%) rotate(0deg)", e.style.opacity = "0", e.style.transition = "opacity 300ms", this.glareElement.appendChild(e), this.element.appendChild(this.glareElement);
43
+ }
44
+ destroy() {
45
+ this.element.removeEventListener("mouseenter", this.onMouseEnter), this.element.removeEventListener("mousemove", this.onMouseMove), this.element.removeEventListener("mouseleave", this.onMouseLeave), this.glareElement && this.glareElement.remove();
46
+ }
47
+ }
48
+ var $ = Object.defineProperty, I = Object.getOwnPropertyDescriptor, u = (i, e, n, t) => {
49
+ for (var s = t > 1 ? void 0 : t ? I(e, n) : e, l = i.length - 1, o; l >= 0; l--)
50
+ (o = i[l]) && (s = (t ? o(e, n, s) : o(s)) || s);
51
+ return t && s && $(e, n, s), s;
52
+ };
53
+ let a = class {
54
+ constructor(i) {
55
+ this.el = i, this.options = {}, this.tiltInstance = null;
56
+ }
57
+ ngOnInit() {
58
+ this.initTilt();
59
+ }
60
+ ngOnChanges(i) {
61
+ this.tiltInstance && (this.tiltInstance.destroy(), this.initTilt());
62
+ }
63
+ initTilt() {
64
+ this.tiltInstance = new O(this.el.nativeElement, this.options);
65
+ }
66
+ ngOnDestroy() {
67
+ this.tiltInstance && this.tiltInstance.destroy();
68
+ }
69
+ };
70
+ u([
71
+ E("tilt")
72
+ ], a.prototype, "options", 2);
73
+ a = u([
74
+ b({
75
+ selector: "[tilt]"
76
+ })
77
+ ], a);
78
+ var _ = Object.getOwnPropertyDescriptor, x = (i, e, n, t) => {
79
+ for (var s = t > 1 ? void 0 : t ? _(e, n) : e, l = i.length - 1, o; l >= 0; l--)
80
+ (o = i[l]) && (s = o(s) || s);
81
+ return s;
82
+ };
83
+ let c = class {
84
+ };
85
+ c = x([
86
+ M({
87
+ declarations: [a],
88
+ exports: [a]
89
+ })
90
+ ], c);
91
+ export {
92
+ a as TiltDirective,
93
+ c as TiltModule
94
+ };
@@ -0,0 +1,6 @@
1
+ (function(s,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@angular/core")):typeof define=="function"&&define.amd?define(["exports","@angular/core"],a):(s=typeof globalThis<"u"?globalThis:s||self,a(s.AngularTiltCard={},s.ng.core))})(this,function(s,a){"use strict";var g=Object.defineProperty,v=(n,e,l)=>e in n?g(n,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[e]=l,h=(n,e,l)=>v(n,typeof e!="symbol"?e+"":e,l);class y{constructor(e,l={}){h(this,"element"),h(this,"options"),h(this,"glareElement",null),h(this,"bounds",null),h(this,"onMouseEnter",()=>{var t;this.bounds=this.element.getBoundingClientRect(),this.element.style.transition="none",(t=this.glareElement)!=null&&t.firstChild&&(this.glareElement.firstChild.style.transition="opacity 100ms")}),h(this,"onMouseMove",t=>{var i;if(!this.bounds)return;const o=t.clientX-this.bounds.left,r=t.clientY-this.bounds.top,m=o/this.bounds.width,u=r/this.bounds.height,c=this.options.max||15,T=(.5-u)*c*2,C=(m-.5)*c*2;if(this.element.style.transform=`
2
+ perspective(${this.options.perspective}px)
3
+ rotateX(${T}deg)
4
+ rotateY(${C}deg)
5
+ scale3d(${this.options.scale}, ${this.options.scale}, ${this.options.scale})
6
+ `,this.options.glare&&(i=this.glareElement)!=null&&i.firstChild){const p=this.glareElement.firstChild,O=Math.atan2(t.clientX-(this.bounds.left+this.bounds.width/2),-(t.clientY-(this.bounds.top+this.bounds.height/2)))*(180/Math.PI),w=Math.sqrt(Math.pow(m-.5,2)+Math.pow(u-.5,2))*2;p.style.transform=`translate(-50%, -50%) rotate(${O}deg)`,p.style.opacity=(w*(this.options.glareMaxOpacity||.5)).toString()}}),h(this,"onMouseLeave",()=>{var t;if(this.element.style.transition="transform 300ms ease-out",this.element.style.transform=`perspective(${this.options.perspective}px) rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)`,this.options.glare&&(t=this.glareElement)!=null&&t.firstChild){const i=this.glareElement.firstChild;i.style.opacity="0",i.style.transition="opacity 300ms"}}),this.element=typeof e=="string"?document.querySelector(e):e,this.options={max:15,perspective:1e3,scale:1.05,glare:!1,glareMaxOpacity:.5,...l},this.element&&this.init()}init(){this.element.style.transformStyle="preserve-3d",this.element.style.transform=`perspective(${this.options.perspective}px)`,this.options.glare&&this.addGlare(),this.element.addEventListener("mouseenter",this.onMouseEnter),this.element.addEventListener("mousemove",this.onMouseMove),this.element.addEventListener("mouseleave",this.onMouseLeave)}addGlare(){this.glareElement=document.createElement("div"),this.glareElement.style.position="absolute",this.glareElement.style.top="0",this.glareElement.style.left="0",this.glareElement.style.width="100%",this.glareElement.style.height="100%",this.glareElement.style.overflow="hidden",this.glareElement.style.pointerEvents="none",this.glareElement.style.borderRadius=getComputedStyle(this.element).borderRadius;const e=document.createElement("div");e.style.position="absolute",e.style.top="50%",e.style.left="50%",e.style.pointerEvents="none",e.style.backgroundImage="linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%)",e.style.width="200%",e.style.height="200%",e.style.transform="translate(-50%, -50%) rotate(0deg)",e.style.opacity="0",e.style.transition="opacity 300ms",this.glareElement.appendChild(e),this.element.appendChild(this.glareElement)}destroy(){this.element.removeEventListener("mouseenter",this.onMouseEnter),this.element.removeEventListener("mousemove",this.onMouseMove),this.element.removeEventListener("mouseleave",this.onMouseLeave),this.glareElement&&this.glareElement.remove()}}var f=Object.defineProperty,E=Object.getOwnPropertyDescriptor,d=(n,e,l,t)=>{for(var i=t>1?void 0:t?E(e,l):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(t?r(e,l,i):r(i))||i);return t&&i&&f(e,l,i),i};s.TiltDirective=class{constructor(e){this.el=e,this.options={},this.tiltInstance=null}ngOnInit(){this.initTilt()}ngOnChanges(e){this.tiltInstance&&(this.tiltInstance.destroy(),this.initTilt())}initTilt(){this.tiltInstance=new y(this.el.nativeElement,this.options)}ngOnDestroy(){this.tiltInstance&&this.tiltInstance.destroy()}},d([a.Input("tilt")],s.TiltDirective.prototype,"options",2),s.TiltDirective=d([a.Directive({selector:"[tilt]"})],s.TiltDirective);var b=Object.getOwnPropertyDescriptor,M=(n,e,l,t)=>{for(var i=t>1?void 0:t?b(e,l):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=r(i)||i);return i};s.TiltModule=class{},s.TiltModule=M([a.NgModule({declarations:[s.TiltDirective],exports:[s.TiltDirective]})],s.TiltModule),Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,13 @@
1
+ import { ElementRef, OnInit, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
2
+ import { TiltOptions } from '@jojovms/tilt-card-core';
3
+
4
+ export declare class TiltDirective implements OnInit, OnDestroy, OnChanges {
5
+ private el;
6
+ options: TiltOptions;
7
+ private tiltInstance;
8
+ constructor(el: ElementRef);
9
+ ngOnInit(): void;
10
+ ngOnChanges(changes: SimpleChanges): void;
11
+ private initTilt;
12
+ ngOnDestroy(): void;
13
+ }
@@ -0,0 +1,2 @@
1
+ export declare class TiltModule {
2
+ }
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@jojovms/angular-tilt-card",
3
+ "version": "0.0.1",
4
+ "description": "Tiltō: A premium 3D tilt interaction effect for your cards (Angular wrapper).",
5
+ "keywords": [
6
+ "tilto",
7
+ "tilt-card",
8
+ "angular",
9
+ "3d",
10
+ "hover",
11
+ "ui",
12
+ "framework",
13
+ "jojovms"
14
+ ],
15
+ "author": "Shijo Shaji (https://shijoshaji.in)",
16
+ "homepage": "https://shijoshaji.in",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/shijoshaji/tilt-card.git",
20
+ "directory": "angular"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/shijoshaji/tilt-card/issues"
24
+ },
25
+ "main": "dist/index.js",
26
+ "module": "dist/index.mjs",
27
+ "types": "dist/index.d.ts",
28
+ "peerDependencies": {
29
+ "@angular/core": "^17.0.0",
30
+ "@angular/common": "^17.0.0",
31
+ "rxjs": "^7.8.0"
32
+ },
33
+ "dependencies": {
34
+ "@jojovms/tilt-card-core": "*"
35
+ },
36
+ "scripts": {
37
+ "build": "vite build"
38
+ },
39
+ "files": [
40
+ "dist"
41
+ ],
42
+ "devDependencies": {
43
+ "vite": "^5.0.10",
44
+ "vite-plugin-dts": "^3.6.4",
45
+ "@angular/core": "^17.0.0",
46
+ "@angular/common": "^17.0.0",
47
+ "rxjs": "^7.8.0",
48
+ "zone.js": "^0.14.0",
49
+ "typescript": "^5.3.3"
50
+ }
51
+ }