开发者社区> 问答> 正文

新浪微博 鼠标悬停到用户头像时弹出的card是怎么实现的

screenshot
没错就是这个神奇的东西。。。还会根据布局自动选择浮在上方还是下方。。。

展开
收起
a123456678 2016-03-25 16:12:45 2270 0
1 条回答
写回答
取消 提交回答
  • Tooltip.prototype.show = function() {
    
        elTopLocation = this.getBoundingClientRect().top;
        elBottomLocation = window.innerHeight - this.getBoundingClientRect().bottom;
        elLeftLocation = this.getBoundingClientRect().left;
        elRightLocation = window.innerWidth - this.getBoundingClientRect().right;
    
        var direction;
        direction = elLeftLocation < minVerticalDistance ? 'right' : 'left';
        direction = elBottomLocation < minHorizonDistance ? 'top' : 'bottom';
    
        $(this).addClass('hint hint--'+direction);
        return this.direction = direction;
    };
    2019-07-17 19:14:37
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载