cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="description">
	<div class="indicator"></div>
	<div class="scrollButton1">go scrollTop 2000px</div>
	<div class="scrollButton2">go scrollTop 1000px with Velocity.js animation</div>
	<div class="scrollButton3">go to targetElements with Velocity.js animation</div>



	Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt nemo consequatur perferendis natus nisi nostrum sed quam laudantium distinctio voluptas officiis ea, deserunt illum ipsam ipsa fugiat est ex velit, harum ullam ab eum illo hic rem quia! Temporibus molestiae totam ab explicabo dignissimos blanditiis ipsam, sapiente eos placeat nostrum doloremque pariatur, beatae, voluptates quidem voluptatum in porro. Iste impedit pariatur adipisci! Expedita dolorum eos quis repellendus sequi aspernatur perferendis nemo voluptates blanditiis, laboriosam nam sint incidunt porro asperiores assumenda neque officia, id. Recusandae soluta, dolore, quis itaque facere dolor sequi tenetur dolorum, id possimus nesciunt odit nihil amet tempora nulla suscipit velit magnam nisi ullam? Nulla dolores quas veniam fuga illo distinctio nihil molestiae vel repudiandae voluptatibus qui, quaerat debitis obcaecati iste minus <p class="scrollTarget">target</p>
quasi placeat enim molestias? Possimus itaque, esse. Quidem, maiores commodi tempora? Magni saepe praesentium, eaque laborum totam ex distinctio reiciendis. Facere cum voluptatem, distinctio ratione nam nisi voluptas excepturi accusantium suscipit qui deleniti dolores possimus, odio quae architecto fugiat fugit at repellat libero laborum minus asperiores maxime. Deleniti iure, praesentium labore laudantium officiis, perferendis, dignissimos eaque debitis sint minus consectetur. At quo assumenda sunt impedit inventore sint nesciunt molestias! Assumenda voluptatem deserunt alias, ex officiis consequuntur!
	Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab autem cum maxime deserunt blanditiis in obcaecati fugit, consectetur earum incidunt recusandae, debitis nihil natus quaerat enim voluptatibus perferendis quam magni. Eius doloribus eaque doloremque ea maxime reprehenderit nisi ducimus recusandae neque, culpa ab accusamus vel necessitatibus rerum, sequi molestiae aliquid dolore earum animi velit porro odit maiores. Possimus nam praesentium quos, reiciendis ab, sequi temporibus tenetur alias libero quo veniam, quaerat obcaecati, neque maxime numquam voluptates eum? Impedit natus explicabo libero alias blanditiis nostrum nam, laborum et ipsam doloremque quos, unde a error maxime incidunt saepe. Ipsum nostrum, aspernatur quisquam.
</div>

            
          
!
            
              .description
	width: 100px
	margin: auto
	position: relative

.indicator
	position: fixed
	top: 10px
	left: 10px
	font-size: 20px
	color: blue

.scrollButton1
	position: fixed
	top: 30px
	left: 10px
	font-size: 20px
	color: red

.scrollButton2
	position: fixed
	left: 10px
	font-size: 20px
	color: red
	top: 50px
	color: green

.scrollButton3
	position: fixed
	left: 10px
	font-size: 20px
	color: red
	top: 70px
	color: purple

.scrollTarget
	font-size: 30px
	color: brown
	opacity: 0
            
          
!
            
              //http://weboook.blog22.fc2.com/blog-entry-415.html

$(window).scroll(function(){
	let scrollTop =$(window).scrollTop();
	$(".indicator").html("Your window, scrollTop: " + scrollTop);
});

$(".scrollButton1").on("click",function(){
	$("body,html").scrollTop(2000);
});

$(".scrollButton2").on("click",function(){
	$(".scrollTarget").velocity("stop");
	$("html").velocity("scroll",{offset:1000});
});

$(".scrollButton3").on("click",function(){
	$("html").velocity("stop");
	$(".scrollTarget").velocity("scroll",{duration: 2000})
	.velocity("transition.flipBounceYIn")
	.velocity("fadeOut",{display: "block"});
});

let offsetValue = $(".scrollTarget").offset().top;
console.log("オフセット対象:" + offsetValue);


let scrollTop = $(".scrollTarget").scrollTop();
console.log("スクロールトップ対象:" + scrollTop);
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console