繁体   English   中英

Facebook代码是如何工作的,例如在某些分辨率或缩放时隐藏

[英]how does facebook ticker work, e.g on certain res or zoom it hides

我一直在努力弄清楚如何制作像Facebook这样的股票。

当您缩放超过110%时,股票行情器会自动隐藏,这是因为股票行情器将开始覆盖整个布局。

我想知道他们是如何做到的? 如何检测何时隐藏股票行情? 它可以捕获javascript中的分辨率吗?

无论他们在做什么,都是通过Javascript完成的。 您可以获取浏览器窗口的宽度和高度以及DOM中的任何元素。

您可以使用纯Javascript,但是jQuery使这变得轻而易举:

// Get the pixel width and height of the window
var window_height = $(window).height();  // not required, but for clarity
var window_width = $(window).width();
var ticker_width = $('div#ticker_wrapper').width();

// ON rezise, do something
$(window).resize(function() {

  // Do a caculation
  var new_width = (window_width/100)*10; // 10% width

  // Adjust the width of the ticker to suit
  $('div#ticker_width').css('width', new_height);

});

在反应路由器的<navlink /> ?

[英]How do I differentiate an active route with an id (e.g /about#contact) from an active route without an id (e.g /about) in react router's <NavLink />?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM