diff --git a/src/lib/card/Card.svelte b/src/lib/card/Card.svelte
index 6e38523..339c13d 100644
--- a/src/lib/card/Card.svelte
+++ b/src/lib/card/Card.svelte
@@ -12,6 +12,7 @@
export let size: SizeType | 'none' = 'sm';
export let horizontal: boolean = false;
export let reverse: boolean = false;
+ export let isMouseEntered:boolean = false;
interface $$Props extends ComponentProps {
img?: string;
@@ -23,7 +24,6 @@
let innerPadding: string;
$: innerPadding = paddings[padding];
-
let cardClass: string;
$: cardClass = twMerge('flex w-full', sizes[size], reverse ? 'flex-col-reverse' : 'flex-col', horizontal && (reverse ? 'md:flex-row-reverse' : 'md:flex-row'), $$restProps.href && 'hover:bg-gray-100 dark:hover:bg-gray-700', !img && innerPadding, $$props.class);
@@ -31,7 +31,8 @@
$: imgCls = twMerge(reverse ? 'rounded-b-lg' : 'rounded-t-lg', horizontal && 'object-cover w-full h-96 md:h-auto md:w-48 md:rounded-none', horizontal && (reverse ? 'md:rounded-e-lg' : 'md:rounded-s-lg'), imgClass);
-
+
+
{#if img}
diff --git a/src/lib/frame/frame.svelte b/src/lib/frame/frame.svelte
index 4258bd3..66e1f67 100644
--- a/src/lib/frame/frame.svelte
+++ b/src/lib/frame/frame.svelte
@@ -7,7 +7,7 @@
export let isMouseTrackRecord: boolean = false;
export let intervalData: number | undefined = undefined;
export let dataURL: string | undefined = undefined;
- export let isTransform: boolean | undefined = undefined;
+ export let isHoverTransform: boolean | undefined = undefined;
export let isMouseEntered:boolean = false;
export let distanceThreshold: number = 10;
export let timeThreshold:number = 500;
@@ -16,7 +16,7 @@
isMouseTrackRecord?: boolean;
dataURL?: string;
intervalData?: number;
- isTransform?:boolean;
+ isHoverTransform?:boolean;
isMouseEntered?:boolean,
distanceThreshold?:number,
timeThreshold?:number
@@ -30,7 +30,7 @@
$: if (isMouseTrackRecord && intervalData != undefined && countTime != 0 && (countTime % intervalData == 0)) {
sendMouseTrackData();
}
-
+
function clearMouseTrackData() {
mouseTrackData = [];
};
@@ -44,7 +44,7 @@
if (dataURL == undefined || mouseTrackData.length == 0) return;
try {
- console.log('mouse movement track data', mouseTrackData);
+ // console.log('mouse movement track data', mouseTrackData);
const body = {data: JSON.stringify(mouseTrackData)};
const res = await fetch(dataURL, {
method:'post',
@@ -109,17 +109,15 @@
if (event instanceof MouseEvent ) {
const mouseEvent = event as MouseEvent;
if (isMouseTrackRecord) {
- console.log('distanceThreshold', distanceThreshold);
- console.log('timeThreshold', timeThreshold);
const temp = recordMouseTrack(oldData, mouseEvent, distanceThreshold, timeThreshold, true);
oldData = { point: temp.point, timestamp: temp.timestamp };
}
- if (isTransform) {
- if (!containerRef || !isTransform) return;
+ if (isHoverTransform) {
+ if (!containerRef || !isHoverTransform) return;
const { left, top, width, height } = containerRef.getBoundingClientRect();
- const x = (-1*(event.clientX - left - width / 2)) / 100;
- const y = (event.clientY - top - height / 2) / 10;
+ const x = (-1*(event.clientX - left - width / 2)) / 25;
+ const y = (event.clientY - top - height / 2) / 25;
containerRef.style.transform = `rotateY(${x}deg) rotateX(${y}deg)`;
}
}
@@ -146,7 +144,8 @@
function handleMouseLeave () {
console.log('stop recording of mouse movement track when is out of card.');
- _clearInterval()
+ _clearInterval();
+ isMouseEntered = false;
if (!containerRef) return;
containerRef.style.transform = `rotateY(0deg) rotateX(0deg)`;
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index f038c87..609098a 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -16,13 +16,13 @@
- Meta stellar card
- Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.
+ Meta stellar card
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.
Metastellar basic card
@@ -52,7 +52,7 @@
intervalData={intervalData}
padding="none"
bind:isMouseEntered
- isTransform>
+ isHoverTransform>