Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
sujata
/
Akruti-Frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 0c70de15
authored
2026-03-12 16:53:45 +0530
by
Ravindra Kanojiya
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
updated video or image option both in video section
1 parent
78ba8b7b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
33 deletions
components/Collection/Video.js
styles/globals.css
components/Collection/Video.js
View file @
0c70de1
import
React
,
{
useRef
,
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useRef
,
useEffect
,
useState
}
from
"react"
;
import
{
Container
}
from
"react-bootstrap
"
;
import
Image
from
"next/image
"
;
import
{
cleanImage
}
from
"../services/imageHandling"
;
import
{
cleanImage
}
from
"../services/imageHandling"
;
const
Video
=
({
productData
})
=>
{
const
Video
=
({
productData
})
=>
{
const
mediaRef
=
useRef
(
null
);
const
videoRef
=
useRef
(
null
);
const
[
isVisible
,
setIsVisible
]
=
useState
(
false
);
const
[
isVisible
,
setIsVisible
]
=
useState
(
false
);
useEffect
(()
=>
{
const
media
=
productData
?.
video
;
const
observer
=
new
IntersectionObserver
(
([
entry
])
=>
{
const
isVideo
=
media
?.
mime
?.
startsWith
(
"video/"
);
if
(
entry
.
isIntersecting
)
{
const
isImage
=
media
?.
mime
?.
startsWith
(
"image/"
);
setIsVisible
(
true
);
useEffect
(()
=>
{
// 👇 Stop observing after first visibility
const
observer
=
new
IntersectionObserver
(
observer
.
unobserve
(
entry
.
target
);
([
entry
])
=>
{
}
if
(
entry
.
isIntersecting
)
{
},
setIsVisible
(
true
);
{
threshold
:
0.5
}
observer
.
unobserve
(
entry
.
target
);
);
}
},
{
threshold
:
0.5
}
);
if
(
videoRef
.
current
)
observer
.
observe
(
video
Ref
.
current
);
if
(
mediaRef
.
current
)
observer
.
observe
(
media
Ref
.
current
);
return
()
=>
{
return
()
=>
{
if
(
videoRef
.
current
)
observer
.
unobserve
(
videoRef
.
current
);
if
(
mediaRef
.
current
)
observer
.
unobserve
(
mediaRef
.
current
);
};
};
},
[]);
},
[]);
if
(
!
media
?.
url
)
return
null
;
return
(
return
(
<
section
className
=
"video_sec"
>
<
section
className
=
"video_sec"
>
<
div
className
=
"custom_containers"
>
<
div
className
=
"custom_containers"
>
<
video
ref
=
{
videoRef
}
{
/* VIDEO */
}
autoPlay
{
isVideo
&&
(
muted
<
video
loop
ref
=
{
mediaRef
}
playsInline
autoPlay
className
=
{
`w-100 video-animate
${
isVisible
?
"video-visible"
:
""
}
`
}
muted
>
loop
<
source
src
=
{
cleanImage
(
productData
?.
video
?.
url
)}
type
=
"video/mp4"
/>
playsInline
Your
browser
does
not
support
the
video
tag
.
className
=
{
`w-100 video-animate
${
isVisible
?
"video-visible"
:
""
}
`
}
<
/video
>
>
<
source
src
=
{
cleanImage
(
media
?.
url
)}
type
=
{
media
?.
mime
||
"video/mp4"
}
/
>
Your
browser
does
not
support
the
video
tag
.
<
/video
>
)}
{
/* IMAGE */
}
{
isImage
&&
(
<
div
ref
=
{
mediaRef
}
className
=
{
`w-100 video-animate
${
isVisible
?
"video-visible"
:
""
}
`
}
>
<
Image
src
=
{
cleanImage
(
media
?.
url
)}
alt
=
{
media
?.
alternativeText
||
media
?.
name
||
"Media"
}
width
=
{
media
?.
width
||
868
}
height
=
{
media
?.
height
||
560
}
className
=
"w-100"
style
=
{{
objectFit
:
"cover"
}}
/
>
<
/div
>
)}
<
/div
>
<
/div
>
<
/section
>
<
/section
>
);
);
};
};
export
default
Video
;
export
default
Video
;
\ No newline at end of file
\ No newline at end of file
styles/globals.css
View file @
0c70de1
...
@@ -345,6 +345,9 @@ button.cust-swiper-button-next {
...
@@ -345,6 +345,9 @@ button.cust-swiper-button-next {
.video-visible
{
.video-visible
{
transform
:
scale
(
1.1
);
transform
:
scale
(
1.1
);
}
}
.video-visible
img
{
height
:
100%
;
}
.video_sec
{
.video_sec
{
overflow
:
hidden
;
overflow
:
hidden
;
}
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment