0

div使用类时ticker,我想在用户s时删除pulseCSS 动画类。ng-mouseenter

我没有仅针对tickerdiv 的指令设置,但是在这种情况下是否有一种简单的方法可以删除或更新pulse类?

标记

<ul>
    <li ng-repeat="tik in tgh.tag.tickers">
        <div class="tag-container" ng-mouseleave="tgh.leaveAssoTicker(tik)">
            <div class="ticker"
                 ng-class="{'fade-1 pulse' : tgh.tag.mainSearch}"
                 ng-mouseenter="tgh.hoverAssoTicker(tik)"
                 ng-click="tgh.selectTicker(tik)">{{tik.ticker}}</div>
            <ticker-hover ticker="tik"></ticker-hover>
        </div>
    </li>
</ul>

鼠标输入函数

function hoverAssoTicker(ticker, type) {
    vs.tickerTagsHoverTimeout = $timeout(function() {

        var theTicker = {};

        if (ticker.ticker === undefined) {
            theTicker.ticker = ticker;
        } else {
            theTicker.ticker = ticker.ticker;
        }

        ApiFactory.getTickerDetails(theTicker.ticker).then(function(data) {

            ticker.longname = data.data.tickers[0].longname;

            if (type === 'portfolio') {
                ticker.removePortfolio = true;
            }
            else if (type === 'searched') {
                ticker.addPortfolio = true;
            }
            else {
               ticker.removePortfolio = false,
               ticker.addPortfolio    = false;
            }

            ticker.tickerHoverDisplay = true;
        });

        vs.closeTagsTikHoverTimer = $timeout(function() {
            if (ticker.tickerHoverDisplay) ticker.tickerHoverDisplay = false;
        }, 2000);

        $rootScope.$broadcast(vs.closeTagsTikHoverTimer);
    }, 500);
}
4

1 回答 1

2

我会使用绑定变量并在 中使用它ng-class,例如ticker.isMouseover. 然后在您的ng-mouseenter事件中,将其设置为 true,反之亦然ng-mouseleave

然后你可以有类似的东西ng-class="{pulse: !tik.isMouseover}"

于 2015-08-06T16:20:00.603 回答