简体   繁体   English

从一个Div到另一个“移入下一个房间”的效果

[英]'Move into next room' effect from one Div to another

I have a centered large div with an image in it, within that image is a doorway to the right. 我有一个居中的大div,其中有一个图像,其中该图像是右侧的门口。 I'm wanting to make it so that when you click the doorway, it 'zooms' to the next image, which will be of the next room. 我要这样做,以便当您单击门口时,它会“缩放”到下一个图像,该图像将是下一个房间的图像。

The best way to describe it is similar to what Street View does when you're going down the road on Google maps. 最好的描述方式与您在Google地图上浏览街景时的操作类似。

Can anybody help? 有人可以帮忙吗? Preferably jQuery, but I am open to anything. 最好是jQuery,但我愿意接受任何东西。 Tried a few Zoom like plugins, but to no affect. 尝试了一些类似Zoom的插件,但没有任何影响。

The ideal solution would be to go to another Div, so I am then able to control the content within the next 'room' (I have interactive objects in each 'room'). 理想的解决方案是转到另一个Div,这样我就可以控制下一个“房间”中的内容(每个“房间”中都有交互式对象)。

Hopefully this makes sense? 希望这有意义吗?

Example I'm working on: http://www.ether-game.com/new 我正在处理的示例: http : //www.ether-game.com/new

Are you looking for this? 您在找这个吗?

http://jsfiddle.net/F9vhD/ http://jsfiddle.net/F9vhD/

You just need to move one div to -100% left of its own width, and the other one the same. 您只需要将一个div移动到其自身宽度的左-100%即可,而另一个则相同。

HTML: HTML:

<div class="room" id="room1">
Room 1
<input type="button" id="nextRoom" value="go to next room" />
</div>
<div class="room" id="room2">
 s
</div>

CSS: CSS:

html,body {
    width:100%;
    height:100%;
    overflow:hidden
}

body {
    margin:0;
    padding:0;
    color:#fff
}

.room {
    height:100%;
    width:100%;
    position:absolute;
    top:0;
    left:0
}

#room1 {
    background:red;
}

#room2 {
    background: blue;
    left:100%
}

JS: JS:

$(document).ready(function() {

    $('#nextRoom').on('click', function() {
            $('#room1').animate({left:'-100%'}); 
        $('#room2').animate({left:'0%'});
    });

});

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

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