我怎样才能把这个例子变成一个“2D”?使用 HTML5 幻灯片网格?

发布于 2024-12-13 07:27:12 字数 149 浏览 2 评论 0原文

我想知道是否可以在 2D 中采用 这种 HTML5 技术,例如我们可以使用箭头键可在 3 x 3 幻灯片网格中导航。

如果有,能否指出来源?

I am wondering if it is possible to adapt this HTML5 technology in 2D, such that e.g. we could use the arrow keys to navigate a 3 by 3 slides grid.

If so, could you indicate a source?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光暖心i 2024-12-20 07:27:12

很久以前写的一个插件:
http://flesler.blogspot.com/2007/10/jqueryscrollto.html
它允许你用 JavaScript 做你想做的事:
http://demos.flesler.com/jquery/scrollTo/

这是一个简要概述您可以使用此插件做什么:

(function () {

  // find a current slide by whatever way you want, 
  // i.e. first slide or one that has some class or something...
  var container = $('.container'), 
      currentSlide = container.find('.slide:first');

  $(document).bind('keydown', function(e) {
    var code = e.keyCode || e.which;
    // 37 – left arrow
    // 39 - right arrow
    // 40 - down arrow
    // 38 - up arrow
    if ( code === 37 || code === 39 || code === 38 || code === 40 ) {
      e.preventDefault();

      switch ( code ) {
        case 37 :
          container.scrollTo ( currentSlide.prev(); );
          break;
        case 39 :
          container.scrollTo ( currentSlide.next(); );
          break;
        case 38 :
          container.scrollTo ( // implement finding one that is above );
          break;
        case 40 :
          container.scrollTo ( // implement findign one that is below );
          break;
    }
  });

} ());

请注意,您的容器需要通过 CSS 设置 overflow:hidden 和尺寸(当然,如果您愿意,也可以通过 JS 进行设置)。您可以在插件页面找到所有要求。

There is a plugin written long time ago:
http://flesler.blogspot.com/2007/10/jqueryscrollto.html
that allows you to do what you desire with JavaScript:
http://demos.flesler.com/jquery/scrollTo/

This is a brief outline of what you could do with this plugin:

(function () {

  // find a current slide by whatever way you want, 
  // i.e. first slide or one that has some class or something...
  var container = $('.container'), 
      currentSlide = container.find('.slide:first');

  $(document).bind('keydown', function(e) {
    var code = e.keyCode || e.which;
    // 37 – left arrow
    // 39 - right arrow
    // 40 - down arrow
    // 38 - up arrow
    if ( code === 37 || code === 39 || code === 38 || code === 40 ) {
      e.preventDefault();

      switch ( code ) {
        case 37 :
          container.scrollTo ( currentSlide.prev(); );
          break;
        case 39 :
          container.scrollTo ( currentSlide.next(); );
          break;
        case 38 :
          container.scrollTo ( // implement finding one that is above );
          break;
        case 40 :
          container.scrollTo ( // implement findign one that is below );
          break;
    }
  });

} ());

Note that your container will need to have overflow:hidden and dimensions set on it from CSS (or of course you can do that from JS if you want to). You can find all requirements in plugins page.

逆流 2024-12-20 07:27:12

谷歌地图长期以来一直在这样做。谷歌地图实际上是巨大的网格,远远超出了你的屏幕所能处理的范围。你得到的只是足够的,这样你就不会碰到丢失的东西。当您完成拖动(而不是单击右/左/上/下箭头)时,它会通过 AJAX 检索更多“图块/幻灯片/图像”以填充已移动的网格部分。

Google maps has been doing this for a long time. Google maps are actually huge grids that extend way beyond what your screen could handle. You get just enough so that you don't bump into the missing ones. When you're done dragging (rather than clicking right/left/up/down arrows) it retrieves more "tiles/slides/images" via AJAX to fill in the part of the grid that was moved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文