placeholder & opacity img lazy load

This commit is contained in:
VividTruthKeeper 2023-02-26 20:26:13 +05:00
parent ea35638589
commit 173f193eea
7 changed files with 18 additions and 7 deletions

View File

@ -8,7 +8,7 @@ import ScrollToTop from "./hooks/ScrollToTop";
import "swiper/swiper.css"; import "swiper/swiper.css";
import "swiper/css/pagination"; import "swiper/css/pagination";
import "swiper/css/navigation"; import "swiper/css/navigation";
import "react-lazy-load-image-component/src/effects/blur.css"; import "react-lazy-load-image-component/src/effects/opacity.css";
import "react-calendar/dist/Calendar.css"; import "react-calendar/dist/Calendar.css";
import "./styles/style.scss"; import "./styles/style.scss";

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -2,7 +2,8 @@
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { LazyLoadImage } from "react-lazy-load-image-component"; import { LazyLoadImage } from "react-lazy-load-image-component";
// Images // Images
import { ReactComponent as ArrRight } from "../../assets/icons/arrow-right.svg"; // import { ReactComponent as ArrRight } from "../../assets/icons/arrow-right.svg";
import placeholder from "../../assets/images/placeholder.webp";
// Components // Components
import NewsCategory from "../global/NewsCategory"; import NewsCategory from "../global/NewsCategory";
import NewsDate from "../global/NewsDate"; import NewsDate from "../global/NewsDate";
@ -24,7 +25,8 @@ const AsideNews = ({ title, date, img, category, link }: Props) => {
src={img} src={img}
alt={img} alt={img}
useIntersectionObserver useIntersectionObserver
effect="blur" effect="opacity"
placeholderSrc={placeholder}
/> />
</div> </div>
<div className="aside-news-info"> <div className="aside-news-info">

View File

@ -3,6 +3,7 @@ import { LazyLoadImage } from "react-lazy-load-image-component";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import placeholder from "../../assets/images/placeholder.webp";
// Types // Types
import { RootState } from "../../types/store.types"; import { RootState } from "../../types/store.types";
@ -18,6 +19,7 @@ const MainImg = () => {
data[0].id > -1 ? ( data[0].id > -1 ? (
<Link to={`/news/${data[0].id}`} className="main-img"> <Link to={`/news/${data[0].id}`} className="main-img">
<LazyLoadImage <LazyLoadImage
placeholderSrc={placeholder}
src={ src={
(data[0].featured_images.length > 0 (data[0].featured_images.length > 0
? data[0].featured_images[0].path ? data[0].featured_images[0].path
@ -29,7 +31,7 @@ const MainImg = () => {
: "") as string : "") as string
} }
useIntersectionObserver useIntersectionObserver
effect="blur" effect="opacity"
/> />
<div className="main-img-overlay"> <div className="main-img-overlay">

View File

@ -1,6 +1,7 @@
// Modules // Modules
import { LazyLoadImage } from "react-lazy-load-image-component"; import { LazyLoadImage } from "react-lazy-load-image-component";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import placeholder from "../../assets/images/placeholder.webp";
interface IProps { interface IProps {
type?: "small" | "big"; type?: "small" | "big";
@ -15,8 +16,9 @@ const ContentItem = ({ type = "small", img, title, id }: IProps) => {
<LazyLoadImage <LazyLoadImage
src={img} src={img}
alt={img} alt={img}
effect="blur" effect="opacity"
useIntersectionObserver useIntersectionObserver
placeholderSrc={placeholder}
style={{ style={{
backgroundImage: `url(${img})`, backgroundImage: `url(${img})`,
backgroundRepeat: "no-repeat", backgroundRepeat: "no-repeat",

View File

@ -7,6 +7,7 @@ import { v4 as uuidv4 } from "uuid";
import NewsCategory from "../global/NewsCategory"; import NewsCategory from "../global/NewsCategory";
import NewsDate from "../global/NewsDate"; import NewsDate from "../global/NewsDate";
import { IPostsData } from "../../types/data.types"; import { IPostsData } from "../../types/data.types";
import placeholder from "../../assets/images/placeholder.webp";
interface Props { interface Props {
id: IPostsData["id"]; id: IPostsData["id"];
@ -26,7 +27,8 @@ const News = ({ id, title, text, categories, date, img }: Props) => {
src={img} src={img}
alt={img} alt={img}
useIntersectionObserver useIntersectionObserver
effect="blur" effect="opacity"
placeholderSrc={placeholder}
/> />
</div> </div>
<div className="news-info"> <div className="news-info">

View File

@ -1,4 +1,5 @@
// Modules // Modules
import placeholder from "../../assets/images/placeholder.webp";
import { LazyLoadImage } from "react-lazy-load-image-component"; import { LazyLoadImage } from "react-lazy-load-image-component";
interface IProps { interface IProps {
@ -9,10 +10,12 @@ const NewsArticleImg = ({ img }: IProps) => {
return ( return (
<div className={"news-article-image"}> <div className={"news-article-image"}>
<LazyLoadImage <LazyLoadImage
delayMethod="debounce"
src={img} src={img}
alt={img} alt={img}
effect="blur" effect="opacity"
useIntersectionObserver useIntersectionObserver
placeholderSrc={placeholder}
/> />
</div> </div>
); );