javascript 级联广告缩放

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 级联广告缩放相关的知识,希望对你有一定的参考价值。

var $content = $('.content');
var $fullWidth = 1340;
var $mediumWidth = 960;
var $mobileWidth = 740;

function scaleContent () {
    var adScale = ad.get('flowlaneScale');
    if (ad.el.width() <= ($fullWidth * adScale) && ad.el.width() > ($mediumWidth * adScale)) {
        // between fullWidth and mediumWidth
        $content.css({
            'transform': 'scale(' + ((ad.el.width() - (0 * adScale)) / ($fullWidth * adScale)) + ')'
        });
        console.log('btw fullWidth and mediumWidth: adScale =', adScale);
    } else if (ad.el.width() <= ($mediumWidth * adScale) && ad.el.width() > ($mobileWidth * adScale)) {
        // between mediumWidth and mobileWidth
        $content.css({
            'transform': 'scale(' + ((ad.el.width() - (0 * adScale)) / ($mediumWidth * adScale)) + ')'
        });
        console.log('btw mediumWidth and mobileWidth: adScale =', adScale);
    } else if (ad.el.width() <= ($mobileWidth * adScale)) {
        // mobileWidth or smaller
        $content.css({
            'transform': 'scale(' + ((ad.el.width() - (0 * adScale)) / ($mobileWidth * adScale)) + ')'
        });
        console.log('mobileWidth or smaller: adScale =', adScale);
    } else {
        // greater than fullWidth
        $content.css({
            'transform': 'scale(1)'
        });
        console.log('greater than fullWidth: adScale =', adScale);
    }
}
ad.on('resized', function () {
    scaleContent();
});
component.on('showStart', scaleContent);

以上是关于javascript 级联广告缩放的主要内容,如果未能解决你的问题,请参考以下文章

在 javascript 中访问级联 JSON

javascript 选择 。动态爱情,级联爱情

javascript 删除猫鼬的级联

javascript 年月日级联菜单

使用 Javascript 获取元素的继承(级联)祖先 CSS 类

Bootstrap Javascript组件,模态框级联open解决方案