@adstage/web-sdk 2.2.1 โ 2.2.3
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/dist/index.cjs.js +71 -17
- package/dist/index.esm.js +71 -17
- package/dist/index.standalone.js +71 -17
- package/package.json +2 -2
- package/src/managers/ads/carousel-slider-manager.ts +31 -1
- package/src/modules/ads/AdsModule.ts +35 -10
- package/src/renderers/base-renderer.ts +10 -6
package/dist/index.cjs.js
CHANGED
|
@@ -392,18 +392,23 @@ class BaseAdRenderer {
|
|
|
392
392
|
getImageStyles(slot) {
|
|
393
393
|
const styles = {
|
|
394
394
|
display: 'block',
|
|
395
|
-
'max-width': '100%',
|
|
396
|
-
height: 'auto',
|
|
397
395
|
'object-position': 'center', // ๐ฏ ์ด๋ฏธ์ง ํญ์ ์ค์ ์ ๋ ฌ
|
|
398
396
|
};
|
|
399
|
-
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ
|
|
397
|
+
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
400
398
|
const parsedWidth = this.parseSizeValue(slot?.width);
|
|
401
399
|
const parsedHeight = this.parseSizeValue(slot?.height);
|
|
402
|
-
|
|
400
|
+
const hasUserDefinedSize = parsedWidth || parsedHeight;
|
|
401
|
+
if (hasUserDefinedSize) {
|
|
402
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
403
403
|
styles.width = '100%';
|
|
404
404
|
styles.height = '100%';
|
|
405
|
-
styles['object-fit'] = 'cover';
|
|
406
|
-
styles['object-position'] = 'center';
|
|
405
|
+
styles['object-fit'] = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
406
|
+
styles['object-position'] = 'center';
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ์๋ณธ ์ด๋ฏธ์ง ํฌ๊ธฐ ์ ์ง
|
|
410
|
+
styles['max-width'] = '100%';
|
|
411
|
+
styles.height = 'auto';
|
|
407
412
|
}
|
|
408
413
|
return styles;
|
|
409
414
|
}
|
|
@@ -911,7 +916,7 @@ class CarouselSliderManager {
|
|
|
911
916
|
let currentSlide = 0;
|
|
912
917
|
const totalSlides = advertisements.length;
|
|
913
918
|
const autoSlideInterval = (options?.autoSlideInterval || 3) * 1000; // ๊ธฐ๋ณธ 3์ด
|
|
914
|
-
// ์ฌ๋ผ์ด๋ ์ด๋ ํจ์ (๋ฌดํ ๋ฃจํ ์ง์)
|
|
919
|
+
// ์ฌ๋ผ์ด๋ ์ด๋ ํจ์ (๋ฌดํ ๋ฃจํ ์ง์ + ๋์ ๋์ด ์กฐ์ )
|
|
915
920
|
const moveToSlide = (index, instant = false) => {
|
|
916
921
|
currentSlide = index;
|
|
917
922
|
// ์ ๋๋ฉ์ด์
์์ ๋นํ์ฑํ (๋ฌดํ ๋ฃจํ์ฉ)
|
|
@@ -923,6 +928,33 @@ class CarouselSliderManager {
|
|
|
923
928
|
}
|
|
924
929
|
// ํญ์ ํผ์ผํธ ๊ธฐ๋ฐ์ผ๋ก ์ด๋
|
|
925
930
|
slideContainer.style.transform = `translateX(-${(100 / extendedAds.length) * currentSlide}%)`;
|
|
931
|
+
// ๐ ๋์ ๋์ด ์กฐ์ : ํ์ฌ ์ฌ๋ผ์ด๋์ ์ด๋ฏธ์ง ๋์ด์ ๋ง์ถฐ ์ปจํ
์ด๋ ๋์ด ์กฐ์
|
|
932
|
+
if (!instant && !slot.height && !slot.width) { // ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ์๋ง
|
|
933
|
+
const currentSlideElement = slideContainer.children[currentSlide];
|
|
934
|
+
if (currentSlideElement) {
|
|
935
|
+
const currentAdElement = currentSlideElement.children[0];
|
|
936
|
+
if (currentAdElement) {
|
|
937
|
+
// ์ด๋ฏธ์ง ์์ ์ฐพ๊ธฐ
|
|
938
|
+
const imgElement = currentAdElement.querySelector('img');
|
|
939
|
+
if (imgElement) {
|
|
940
|
+
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ํ ๋์ด ์กฐ์
|
|
941
|
+
const adjustHeight = () => {
|
|
942
|
+
const imgHeight = imgElement.getBoundingClientRect().height;
|
|
943
|
+
if (imgHeight > 0) {
|
|
944
|
+
sliderWrapper.style.height = `${imgHeight}px`;
|
|
945
|
+
sliderWrapper.style.transition = instant ? 'none' : 'height 0.4s ease-out';
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
if (imgElement.complete && imgElement.naturalHeight > 0) {
|
|
949
|
+
adjustHeight();
|
|
950
|
+
}
|
|
951
|
+
else {
|
|
952
|
+
imgElement.addEventListener('load', adjustHeight, { once: true });
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
926
958
|
// ๋ํธ ์
๋ฐ์ดํธ (๋ฌด์ฑ์ ์คํ์ผ) - ์ค์ ๊ด๊ณ ์ธ๋ฑ์ค ๊ธฐ์ค, ํ
์คํธ ๊ด๊ณ ๊ฐ ์๋ ๋๋ง
|
|
927
959
|
const actualIndex = currentSlide === totalSlides ? 0 : currentSlide;
|
|
928
960
|
if (dotContainer) {
|
|
@@ -2886,23 +2918,45 @@ class AdsModule {
|
|
|
2886
2918
|
*/
|
|
2887
2919
|
async renderOptimizedBannerImage(adElement, ad, slot) {
|
|
2888
2920
|
try {
|
|
2889
|
-
//
|
|
2890
|
-
const
|
|
2891
|
-
const
|
|
2892
|
-
|
|
2893
|
-
|
|
2921
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
2922
|
+
const configWidth = slot.config?.width;
|
|
2923
|
+
const configHeight = slot.config?.height;
|
|
2924
|
+
const hasUserDefinedWidth = configWidth &&
|
|
2925
|
+
(typeof configWidth === 'number' || (typeof configWidth === 'string' && configWidth !== '100%'));
|
|
2926
|
+
const hasUserDefinedHeight = configHeight &&
|
|
2927
|
+
(typeof configHeight === 'number' || (typeof configHeight === 'string' && configHeight !== 'auto'));
|
|
2928
|
+
const hasUserDefinedSize = hasUserDefinedWidth || hasUserDefinedHeight;
|
|
2894
2929
|
// ์ด๋ฏธ์ง ์์ ์์ฑ
|
|
2895
2930
|
const img = document.createElement('img');
|
|
2896
2931
|
img.src = ad.imageUrl;
|
|
2897
2932
|
img.alt = ad.title;
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2933
|
+
if (hasUserDefinedSize) {
|
|
2934
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
2935
|
+
img.style.width = '100%';
|
|
2936
|
+
img.style.height = '100%';
|
|
2937
|
+
img.style.objectFit = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
2938
|
+
img.style.objectPosition = 'center';
|
|
2939
|
+
if (this._config?.debug) {
|
|
2940
|
+
console.log(`๐ฏ User-defined size detected: filling container completely`);
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
else {
|
|
2944
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ๋์ ์ต์ ํ ์ ์ฉ
|
|
2945
|
+
const imageDimensions = await this.loadImageDimensions(ad.imageUrl);
|
|
2946
|
+
const imageAspectRatio = imageDimensions.width / imageDimensions.height;
|
|
2947
|
+
const containerAspectRatio = slot.aspectRatio || 16 / 9;
|
|
2948
|
+
img.style.width = '100%';
|
|
2949
|
+
img.style.height = '100%';
|
|
2950
|
+
// ๐จ ์ต์ ํ๋ ์คํ์ผ ์ ์ฉ
|
|
2951
|
+
this.applyOptimizedImageStyle(img, imageAspectRatio, containerAspectRatio);
|
|
2952
|
+
if (this._config?.debug) {
|
|
2953
|
+
console.log(`๐ผ๏ธ Optimized banner image loaded: ${imageDimensions.width}x${imageDimensions.height} (ratio: ${imageAspectRatio.toFixed(2)})`);
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2902
2956
|
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ์ฒ๋ฆฌ
|
|
2903
2957
|
img.onload = () => {
|
|
2904
2958
|
if (this._config?.debug) {
|
|
2905
|
-
console.log(
|
|
2959
|
+
console.log(`โ
Banner image loaded successfully`);
|
|
2906
2960
|
}
|
|
2907
2961
|
};
|
|
2908
2962
|
// ์๋ฌ ์ฒ๋ฆฌ
|
package/dist/index.esm.js
CHANGED
|
@@ -390,18 +390,23 @@ class BaseAdRenderer {
|
|
|
390
390
|
getImageStyles(slot) {
|
|
391
391
|
const styles = {
|
|
392
392
|
display: 'block',
|
|
393
|
-
'max-width': '100%',
|
|
394
|
-
height: 'auto',
|
|
395
393
|
'object-position': 'center', // ๐ฏ ์ด๋ฏธ์ง ํญ์ ์ค์ ์ ๋ ฌ
|
|
396
394
|
};
|
|
397
|
-
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ
|
|
395
|
+
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
398
396
|
const parsedWidth = this.parseSizeValue(slot?.width);
|
|
399
397
|
const parsedHeight = this.parseSizeValue(slot?.height);
|
|
400
|
-
|
|
398
|
+
const hasUserDefinedSize = parsedWidth || parsedHeight;
|
|
399
|
+
if (hasUserDefinedSize) {
|
|
400
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
401
401
|
styles.width = '100%';
|
|
402
402
|
styles.height = '100%';
|
|
403
|
-
styles['object-fit'] = 'cover';
|
|
404
|
-
styles['object-position'] = 'center';
|
|
403
|
+
styles['object-fit'] = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
404
|
+
styles['object-position'] = 'center';
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ์๋ณธ ์ด๋ฏธ์ง ํฌ๊ธฐ ์ ์ง
|
|
408
|
+
styles['max-width'] = '100%';
|
|
409
|
+
styles.height = 'auto';
|
|
405
410
|
}
|
|
406
411
|
return styles;
|
|
407
412
|
}
|
|
@@ -909,7 +914,7 @@ class CarouselSliderManager {
|
|
|
909
914
|
let currentSlide = 0;
|
|
910
915
|
const totalSlides = advertisements.length;
|
|
911
916
|
const autoSlideInterval = (options?.autoSlideInterval || 3) * 1000; // ๊ธฐ๋ณธ 3์ด
|
|
912
|
-
// ์ฌ๋ผ์ด๋ ์ด๋ ํจ์ (๋ฌดํ ๋ฃจํ ์ง์)
|
|
917
|
+
// ์ฌ๋ผ์ด๋ ์ด๋ ํจ์ (๋ฌดํ ๋ฃจํ ์ง์ + ๋์ ๋์ด ์กฐ์ )
|
|
913
918
|
const moveToSlide = (index, instant = false) => {
|
|
914
919
|
currentSlide = index;
|
|
915
920
|
// ์ ๋๋ฉ์ด์
์์ ๋นํ์ฑํ (๋ฌดํ ๋ฃจํ์ฉ)
|
|
@@ -921,6 +926,33 @@ class CarouselSliderManager {
|
|
|
921
926
|
}
|
|
922
927
|
// ํญ์ ํผ์ผํธ ๊ธฐ๋ฐ์ผ๋ก ์ด๋
|
|
923
928
|
slideContainer.style.transform = `translateX(-${(100 / extendedAds.length) * currentSlide}%)`;
|
|
929
|
+
// ๐ ๋์ ๋์ด ์กฐ์ : ํ์ฌ ์ฌ๋ผ์ด๋์ ์ด๋ฏธ์ง ๋์ด์ ๋ง์ถฐ ์ปจํ
์ด๋ ๋์ด ์กฐ์
|
|
930
|
+
if (!instant && !slot.height && !slot.width) { // ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ์๋ง
|
|
931
|
+
const currentSlideElement = slideContainer.children[currentSlide];
|
|
932
|
+
if (currentSlideElement) {
|
|
933
|
+
const currentAdElement = currentSlideElement.children[0];
|
|
934
|
+
if (currentAdElement) {
|
|
935
|
+
// ์ด๋ฏธ์ง ์์ ์ฐพ๊ธฐ
|
|
936
|
+
const imgElement = currentAdElement.querySelector('img');
|
|
937
|
+
if (imgElement) {
|
|
938
|
+
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ํ ๋์ด ์กฐ์
|
|
939
|
+
const adjustHeight = () => {
|
|
940
|
+
const imgHeight = imgElement.getBoundingClientRect().height;
|
|
941
|
+
if (imgHeight > 0) {
|
|
942
|
+
sliderWrapper.style.height = `${imgHeight}px`;
|
|
943
|
+
sliderWrapper.style.transition = instant ? 'none' : 'height 0.4s ease-out';
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
if (imgElement.complete && imgElement.naturalHeight > 0) {
|
|
947
|
+
adjustHeight();
|
|
948
|
+
}
|
|
949
|
+
else {
|
|
950
|
+
imgElement.addEventListener('load', adjustHeight, { once: true });
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
924
956
|
// ๋ํธ ์
๋ฐ์ดํธ (๋ฌด์ฑ์ ์คํ์ผ) - ์ค์ ๊ด๊ณ ์ธ๋ฑ์ค ๊ธฐ์ค, ํ
์คํธ ๊ด๊ณ ๊ฐ ์๋ ๋๋ง
|
|
925
957
|
const actualIndex = currentSlide === totalSlides ? 0 : currentSlide;
|
|
926
958
|
if (dotContainer) {
|
|
@@ -2884,23 +2916,45 @@ class AdsModule {
|
|
|
2884
2916
|
*/
|
|
2885
2917
|
async renderOptimizedBannerImage(adElement, ad, slot) {
|
|
2886
2918
|
try {
|
|
2887
|
-
//
|
|
2888
|
-
const
|
|
2889
|
-
const
|
|
2890
|
-
|
|
2891
|
-
|
|
2919
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
2920
|
+
const configWidth = slot.config?.width;
|
|
2921
|
+
const configHeight = slot.config?.height;
|
|
2922
|
+
const hasUserDefinedWidth = configWidth &&
|
|
2923
|
+
(typeof configWidth === 'number' || (typeof configWidth === 'string' && configWidth !== '100%'));
|
|
2924
|
+
const hasUserDefinedHeight = configHeight &&
|
|
2925
|
+
(typeof configHeight === 'number' || (typeof configHeight === 'string' && configHeight !== 'auto'));
|
|
2926
|
+
const hasUserDefinedSize = hasUserDefinedWidth || hasUserDefinedHeight;
|
|
2892
2927
|
// ์ด๋ฏธ์ง ์์ ์์ฑ
|
|
2893
2928
|
const img = document.createElement('img');
|
|
2894
2929
|
img.src = ad.imageUrl;
|
|
2895
2930
|
img.alt = ad.title;
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2931
|
+
if (hasUserDefinedSize) {
|
|
2932
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
2933
|
+
img.style.width = '100%';
|
|
2934
|
+
img.style.height = '100%';
|
|
2935
|
+
img.style.objectFit = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
2936
|
+
img.style.objectPosition = 'center';
|
|
2937
|
+
if (this._config?.debug) {
|
|
2938
|
+
console.log(`๐ฏ User-defined size detected: filling container completely`);
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
else {
|
|
2942
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ๋์ ์ต์ ํ ์ ์ฉ
|
|
2943
|
+
const imageDimensions = await this.loadImageDimensions(ad.imageUrl);
|
|
2944
|
+
const imageAspectRatio = imageDimensions.width / imageDimensions.height;
|
|
2945
|
+
const containerAspectRatio = slot.aspectRatio || 16 / 9;
|
|
2946
|
+
img.style.width = '100%';
|
|
2947
|
+
img.style.height = '100%';
|
|
2948
|
+
// ๐จ ์ต์ ํ๋ ์คํ์ผ ์ ์ฉ
|
|
2949
|
+
this.applyOptimizedImageStyle(img, imageAspectRatio, containerAspectRatio);
|
|
2950
|
+
if (this._config?.debug) {
|
|
2951
|
+
console.log(`๐ผ๏ธ Optimized banner image loaded: ${imageDimensions.width}x${imageDimensions.height} (ratio: ${imageAspectRatio.toFixed(2)})`);
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2900
2954
|
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ์ฒ๋ฆฌ
|
|
2901
2955
|
img.onload = () => {
|
|
2902
2956
|
if (this._config?.debug) {
|
|
2903
|
-
console.log(
|
|
2957
|
+
console.log(`โ
Banner image loaded successfully`);
|
|
2904
2958
|
}
|
|
2905
2959
|
};
|
|
2906
2960
|
// ์๋ฌ ์ฒ๋ฆฌ
|
package/dist/index.standalone.js
CHANGED
|
@@ -390,18 +390,23 @@ class BaseAdRenderer {
|
|
|
390
390
|
getImageStyles(slot) {
|
|
391
391
|
const styles = {
|
|
392
392
|
display: 'block',
|
|
393
|
-
'max-width': '100%',
|
|
394
|
-
height: 'auto',
|
|
395
393
|
'object-position': 'center', // ๐ฏ ์ด๋ฏธ์ง ํญ์ ์ค์ ์ ๋ ฌ
|
|
396
394
|
};
|
|
397
|
-
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ
|
|
395
|
+
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
398
396
|
const parsedWidth = this.parseSizeValue(slot?.width);
|
|
399
397
|
const parsedHeight = this.parseSizeValue(slot?.height);
|
|
400
|
-
|
|
398
|
+
const hasUserDefinedSize = parsedWidth || parsedHeight;
|
|
399
|
+
if (hasUserDefinedSize) {
|
|
400
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
401
401
|
styles.width = '100%';
|
|
402
402
|
styles.height = '100%';
|
|
403
|
-
styles['object-fit'] = 'cover';
|
|
404
|
-
styles['object-position'] = 'center';
|
|
403
|
+
styles['object-fit'] = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
404
|
+
styles['object-position'] = 'center';
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ์๋ณธ ์ด๋ฏธ์ง ํฌ๊ธฐ ์ ์ง
|
|
408
|
+
styles['max-width'] = '100%';
|
|
409
|
+
styles.height = 'auto';
|
|
405
410
|
}
|
|
406
411
|
return styles;
|
|
407
412
|
}
|
|
@@ -909,7 +914,7 @@ class CarouselSliderManager {
|
|
|
909
914
|
let currentSlide = 0;
|
|
910
915
|
const totalSlides = advertisements.length;
|
|
911
916
|
const autoSlideInterval = (options?.autoSlideInterval || 3) * 1000; // ๊ธฐ๋ณธ 3์ด
|
|
912
|
-
// ์ฌ๋ผ์ด๋ ์ด๋ ํจ์ (๋ฌดํ ๋ฃจํ ์ง์)
|
|
917
|
+
// ์ฌ๋ผ์ด๋ ์ด๋ ํจ์ (๋ฌดํ ๋ฃจํ ์ง์ + ๋์ ๋์ด ์กฐ์ )
|
|
913
918
|
const moveToSlide = (index, instant = false) => {
|
|
914
919
|
currentSlide = index;
|
|
915
920
|
// ์ ๋๋ฉ์ด์
์์ ๋นํ์ฑํ (๋ฌดํ ๋ฃจํ์ฉ)
|
|
@@ -921,6 +926,33 @@ class CarouselSliderManager {
|
|
|
921
926
|
}
|
|
922
927
|
// ํญ์ ํผ์ผํธ ๊ธฐ๋ฐ์ผ๋ก ์ด๋
|
|
923
928
|
slideContainer.style.transform = `translateX(-${(100 / extendedAds.length) * currentSlide}%)`;
|
|
929
|
+
// ๐ ๋์ ๋์ด ์กฐ์ : ํ์ฌ ์ฌ๋ผ์ด๋์ ์ด๋ฏธ์ง ๋์ด์ ๋ง์ถฐ ์ปจํ
์ด๋ ๋์ด ์กฐ์
|
|
930
|
+
if (!instant && !slot.height && !slot.width) { // ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ์๋ง
|
|
931
|
+
const currentSlideElement = slideContainer.children[currentSlide];
|
|
932
|
+
if (currentSlideElement) {
|
|
933
|
+
const currentAdElement = currentSlideElement.children[0];
|
|
934
|
+
if (currentAdElement) {
|
|
935
|
+
// ์ด๋ฏธ์ง ์์ ์ฐพ๊ธฐ
|
|
936
|
+
const imgElement = currentAdElement.querySelector('img');
|
|
937
|
+
if (imgElement) {
|
|
938
|
+
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ํ ๋์ด ์กฐ์
|
|
939
|
+
const adjustHeight = () => {
|
|
940
|
+
const imgHeight = imgElement.getBoundingClientRect().height;
|
|
941
|
+
if (imgHeight > 0) {
|
|
942
|
+
sliderWrapper.style.height = `${imgHeight}px`;
|
|
943
|
+
sliderWrapper.style.transition = instant ? 'none' : 'height 0.4s ease-out';
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
if (imgElement.complete && imgElement.naturalHeight > 0) {
|
|
947
|
+
adjustHeight();
|
|
948
|
+
}
|
|
949
|
+
else {
|
|
950
|
+
imgElement.addEventListener('load', adjustHeight, { once: true });
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
924
956
|
// ๋ํธ ์
๋ฐ์ดํธ (๋ฌด์ฑ์ ์คํ์ผ) - ์ค์ ๊ด๊ณ ์ธ๋ฑ์ค ๊ธฐ์ค, ํ
์คํธ ๊ด๊ณ ๊ฐ ์๋ ๋๋ง
|
|
925
957
|
const actualIndex = currentSlide === totalSlides ? 0 : currentSlide;
|
|
926
958
|
if (dotContainer) {
|
|
@@ -2884,23 +2916,45 @@ class AdsModule {
|
|
|
2884
2916
|
*/
|
|
2885
2917
|
async renderOptimizedBannerImage(adElement, ad, slot) {
|
|
2886
2918
|
try {
|
|
2887
|
-
//
|
|
2888
|
-
const
|
|
2889
|
-
const
|
|
2890
|
-
|
|
2891
|
-
|
|
2919
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
2920
|
+
const configWidth = slot.config?.width;
|
|
2921
|
+
const configHeight = slot.config?.height;
|
|
2922
|
+
const hasUserDefinedWidth = configWidth &&
|
|
2923
|
+
(typeof configWidth === 'number' || (typeof configWidth === 'string' && configWidth !== '100%'));
|
|
2924
|
+
const hasUserDefinedHeight = configHeight &&
|
|
2925
|
+
(typeof configHeight === 'number' || (typeof configHeight === 'string' && configHeight !== 'auto'));
|
|
2926
|
+
const hasUserDefinedSize = hasUserDefinedWidth || hasUserDefinedHeight;
|
|
2892
2927
|
// ์ด๋ฏธ์ง ์์ ์์ฑ
|
|
2893
2928
|
const img = document.createElement('img');
|
|
2894
2929
|
img.src = ad.imageUrl;
|
|
2895
2930
|
img.alt = ad.title;
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2931
|
+
if (hasUserDefinedSize) {
|
|
2932
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
2933
|
+
img.style.width = '100%';
|
|
2934
|
+
img.style.height = '100%';
|
|
2935
|
+
img.style.objectFit = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
2936
|
+
img.style.objectPosition = 'center';
|
|
2937
|
+
if (this._config?.debug) {
|
|
2938
|
+
console.log(`๐ฏ User-defined size detected: filling container completely`);
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
else {
|
|
2942
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ๋์ ์ต์ ํ ์ ์ฉ
|
|
2943
|
+
const imageDimensions = await this.loadImageDimensions(ad.imageUrl);
|
|
2944
|
+
const imageAspectRatio = imageDimensions.width / imageDimensions.height;
|
|
2945
|
+
const containerAspectRatio = slot.aspectRatio || 16 / 9;
|
|
2946
|
+
img.style.width = '100%';
|
|
2947
|
+
img.style.height = '100%';
|
|
2948
|
+
// ๐จ ์ต์ ํ๋ ์คํ์ผ ์ ์ฉ
|
|
2949
|
+
this.applyOptimizedImageStyle(img, imageAspectRatio, containerAspectRatio);
|
|
2950
|
+
if (this._config?.debug) {
|
|
2951
|
+
console.log(`๐ผ๏ธ Optimized banner image loaded: ${imageDimensions.width}x${imageDimensions.height} (ratio: ${imageAspectRatio.toFixed(2)})`);
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2900
2954
|
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ์ฒ๋ฆฌ
|
|
2901
2955
|
img.onload = () => {
|
|
2902
2956
|
if (this._config?.debug) {
|
|
2903
|
-
console.log(
|
|
2957
|
+
console.log(`โ
Banner image loaded successfully`);
|
|
2904
2958
|
}
|
|
2905
2959
|
};
|
|
2906
2960
|
// ์๋ฌ ์ฒ๋ฆฌ
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adstage/web-sdk",
|
|
3
|
-
"version": "2.2.
|
|
4
|
-
"description": "AdStage Web SDK - Production-ready marketing platform SDK with auto-initialization, dynamic sizing,
|
|
3
|
+
"version": "2.2.3",
|
|
4
|
+
"description": "AdStage Web SDK - Production-ready marketing platform SDK with auto-initialization, dynamic sizing, centered image positioning, user-defined size support, and adaptive height adjustment",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -184,7 +184,7 @@ export class CarouselSliderManager {
|
|
|
184
184
|
const totalSlides = advertisements.length;
|
|
185
185
|
const autoSlideInterval = (options?.autoSlideInterval || 3) * 1000; // ๊ธฐ๋ณธ 3์ด
|
|
186
186
|
|
|
187
|
-
// ์ฌ๋ผ์ด๋ ์ด๋ ํจ์ (๋ฌดํ ๋ฃจํ ์ง์)
|
|
187
|
+
// ์ฌ๋ผ์ด๋ ์ด๋ ํจ์ (๋ฌดํ ๋ฃจํ ์ง์ + ๋์ ๋์ด ์กฐ์ )
|
|
188
188
|
const moveToSlide = (index: number, instant = false) => {
|
|
189
189
|
currentSlide = index;
|
|
190
190
|
|
|
@@ -198,6 +198,36 @@ export class CarouselSliderManager {
|
|
|
198
198
|
// ํญ์ ํผ์ผํธ ๊ธฐ๋ฐ์ผ๋ก ์ด๋
|
|
199
199
|
slideContainer.style.transform = `translateX(-${(100 / extendedAds.length) * currentSlide}%)`;
|
|
200
200
|
|
|
201
|
+
// ๐ ๋์ ๋์ด ์กฐ์ : ํ์ฌ ์ฌ๋ผ์ด๋์ ์ด๋ฏธ์ง ๋์ด์ ๋ง์ถฐ ์ปจํ
์ด๋ ๋์ด ์กฐ์
|
|
202
|
+
if (!instant && !slot.height && !slot.width) { // ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ์๋ง
|
|
203
|
+
const actualIndex = currentSlide === totalSlides ? 0 : currentSlide;
|
|
204
|
+
const currentSlideElement = slideContainer.children[currentSlide] as HTMLElement;
|
|
205
|
+
|
|
206
|
+
if (currentSlideElement) {
|
|
207
|
+
const currentAdElement = currentSlideElement.children[0] as HTMLElement;
|
|
208
|
+
if (currentAdElement) {
|
|
209
|
+
// ์ด๋ฏธ์ง ์์ ์ฐพ๊ธฐ
|
|
210
|
+
const imgElement = currentAdElement.querySelector('img');
|
|
211
|
+
if (imgElement) {
|
|
212
|
+
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ํ ๋์ด ์กฐ์
|
|
213
|
+
const adjustHeight = () => {
|
|
214
|
+
const imgHeight = imgElement.getBoundingClientRect().height;
|
|
215
|
+
if (imgHeight > 0) {
|
|
216
|
+
sliderWrapper.style.height = `${imgHeight}px`;
|
|
217
|
+
sliderWrapper.style.transition = instant ? 'none' : 'height 0.4s ease-out';
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
if (imgElement.complete && imgElement.naturalHeight > 0) {
|
|
222
|
+
adjustHeight();
|
|
223
|
+
} else {
|
|
224
|
+
imgElement.addEventListener('load', adjustHeight, { once: true });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
201
231
|
// ๋ํธ ์
๋ฐ์ดํธ (๋ฌด์ฑ์ ์คํ์ผ) - ์ค์ ๊ด๊ณ ์ธ๋ฑ์ค ๊ธฐ์ค, ํ
์คํธ ๊ด๊ณ ๊ฐ ์๋ ๋๋ง
|
|
202
232
|
const actualIndex = currentSlide === totalSlides ? 0 : currentSlide;
|
|
203
233
|
if (dotContainer) {
|
|
@@ -1076,27 +1076,52 @@ export class AdsModule implements BaseModule {
|
|
|
1076
1076
|
*/
|
|
1077
1077
|
private async renderOptimizedBannerImage(adElement: HTMLElement, ad: Advertisement, slot: AdSlot): Promise<void> {
|
|
1078
1078
|
try {
|
|
1079
|
-
//
|
|
1080
|
-
const
|
|
1081
|
-
const
|
|
1079
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
1080
|
+
const configWidth = slot.config?.width;
|
|
1081
|
+
const configHeight = slot.config?.height;
|
|
1082
1082
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1083
|
+
const hasUserDefinedWidth = configWidth &&
|
|
1084
|
+
(typeof configWidth === 'number' || (typeof configWidth === 'string' && configWidth !== '100%'));
|
|
1085
|
+
const hasUserDefinedHeight = configHeight &&
|
|
1086
|
+
(typeof configHeight === 'number' || (typeof configHeight === 'string' && configHeight !== 'auto'));
|
|
1087
|
+
const hasUserDefinedSize = hasUserDefinedWidth || hasUserDefinedHeight;
|
|
1085
1088
|
|
|
1086
1089
|
// ์ด๋ฏธ์ง ์์ ์์ฑ
|
|
1087
1090
|
const img = document.createElement('img');
|
|
1088
1091
|
img.src = ad.imageUrl!;
|
|
1089
1092
|
img.alt = ad.title;
|
|
1090
|
-
img.style.width = '100%';
|
|
1091
|
-
img.style.height = '100%';
|
|
1092
1093
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1094
|
+
if (hasUserDefinedSize) {
|
|
1095
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
1096
|
+
img.style.width = '100%';
|
|
1097
|
+
img.style.height = '100%';
|
|
1098
|
+
img.style.objectFit = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
1099
|
+
img.style.objectPosition = 'center';
|
|
1100
|
+
|
|
1101
|
+
if (this._config?.debug) {
|
|
1102
|
+
console.log(`๐ฏ User-defined size detected: filling container completely`);
|
|
1103
|
+
}
|
|
1104
|
+
} else {
|
|
1105
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ๋์ ์ต์ ํ ์ ์ฉ
|
|
1106
|
+
const imageDimensions = await this.loadImageDimensions(ad.imageUrl!);
|
|
1107
|
+
const imageAspectRatio = imageDimensions.width / imageDimensions.height;
|
|
1108
|
+
const containerAspectRatio = (slot as any).aspectRatio || 16/9;
|
|
1109
|
+
|
|
1110
|
+
img.style.width = '100%';
|
|
1111
|
+
img.style.height = '100%';
|
|
1112
|
+
|
|
1113
|
+
// ๐จ ์ต์ ํ๋ ์คํ์ผ ์ ์ฉ
|
|
1114
|
+
this.applyOptimizedImageStyle(img, imageAspectRatio, containerAspectRatio);
|
|
1115
|
+
|
|
1116
|
+
if (this._config?.debug) {
|
|
1117
|
+
console.log(`๐ผ๏ธ Optimized banner image loaded: ${imageDimensions.width}x${imageDimensions.height} (ratio: ${imageAspectRatio.toFixed(2)})`);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1095
1120
|
|
|
1096
1121
|
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ์ฒ๋ฆฌ
|
|
1097
1122
|
img.onload = () => {
|
|
1098
1123
|
if (this._config?.debug) {
|
|
1099
|
-
console.log(
|
|
1124
|
+
console.log(`โ
Banner image loaded successfully`);
|
|
1100
1125
|
}
|
|
1101
1126
|
};
|
|
1102
1127
|
|
|
@@ -108,20 +108,24 @@ export abstract class BaseAdRenderer implements AdRenderer {
|
|
|
108
108
|
protected getImageStyles(slot?: AdSlot): Record<string, string> {
|
|
109
109
|
const styles: Record<string, string> = {
|
|
110
110
|
display: 'block',
|
|
111
|
-
'max-width': '100%',
|
|
112
|
-
height: 'auto',
|
|
113
111
|
'object-position': 'center', // ๐ฏ ์ด๋ฏธ์ง ํญ์ ์ค์ ์ ๋ ฌ
|
|
114
112
|
};
|
|
115
113
|
|
|
116
|
-
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ
|
|
114
|
+
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
117
115
|
const parsedWidth = this.parseSizeValue(slot?.width);
|
|
118
116
|
const parsedHeight = this.parseSizeValue(slot?.height);
|
|
117
|
+
const hasUserDefinedSize = parsedWidth || parsedHeight;
|
|
119
118
|
|
|
120
|
-
if (
|
|
119
|
+
if (hasUserDefinedSize) {
|
|
120
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
121
121
|
styles.width = '100%';
|
|
122
122
|
styles.height = '100%';
|
|
123
|
-
styles['object-fit'] = 'cover';
|
|
124
|
-
styles['object-position'] = 'center';
|
|
123
|
+
styles['object-fit'] = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
124
|
+
styles['object-position'] = 'center';
|
|
125
|
+
} else {
|
|
126
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ์๋ณธ ์ด๋ฏธ์ง ํฌ๊ธฐ ์ ์ง
|
|
127
|
+
styles['max-width'] = '100%';
|
|
128
|
+
styles.height = 'auto';
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
return styles;
|