npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tomk79/sidebar-fix

v1.2.0

Published

サイドバーをブラウザの表示エリア内に固定するライブラリです。ブラウザで動作します。

Downloads

4

Readme

sidebarFix.js

サイドバーをブラウザの表示エリア内に固定するライブラリです。ブラウザで動作します。 サイドバーが画面の高さよりも長い場合でも、サイドバーの全体が見きれないように自動的に位置を調整します。

jQueryプラグイン版 jquery.sidebarFix.js と、jQueryを内蔵したスタンドアローン版 sidebarFix.js を同梱しています。

使い方 - Usage

jQuery プラグインとして使う - Using as a jQuery Plugin

<!doctype html>
<html>
	<head>
		<title>jquery.sidebarFix.js SAMPLE</title>
	</head>
	<body>
		<div class="header">
			header
		</div>
		<div class="sidebar-fix-container">
			<div class="column1">
				Contents Area
			</div>
			<div class="column2">
				<div class="sidebar-fix">
					Sidebar
				</div>
			</div>
		</div>
		<div class="footer">
			footer
		</div>

		<!-- jQuery required -->
		<script src="sample_files/jquery-3.6.0.min.js" type="text/javascript"></script>

		<!-- loading jquery.sidebarFix.js -->
		<script src="jquery.sidebarFix.js" type="text/javascript"></script>

		<script type="text/javascript">
			$(window).on('load', function(){
				// .sidebar-fix を固定します
				$('.sidebar-fix').sidebarFix({
					frame: $('.sidebar-fix-container'), // .sidebar-fix-container の上下を基準にフィットさせます
					topBuffer: 100, // スクロールに対して常に上に隙間をとる場合に指定。(固定ヘッダーがある場合など)
					force: true // 強制的に固定します。固定座標がズレる場合に指定すると、矯正的に補正します。
				});
			});
		</script>
	</body>
</html>

スタンドアローンで使う - Using without jQuery

<!doctype html>
<html>
	<head>
		<title>sidebarFix.js SAMPLE</title>
	</head>
	<body>
		<div class="header">
			header
		</div>
		<div class="sidebar-fix-container">
			<div class="column1">
				Contents Area
			</div>
			<div class="column2">
				<div class="sidebar-fix">
					Sidebar
				</div>
			</div>
		</div>
		<div class="footer">
			footer
		</div>

		<!-- loading sidebarFix.js -->
		<script src="sidebarFix.js" type="text/javascript"></script>

		<script type="text/javascript">
			window.addEventListener('load', function(){
				// .sidebar-fix を固定します
				sidebarFix('.sidebar-fix', {
					frame: $('.sidebar-fix-container'),
					topBuffer: 100,
					force: true
				});
			});
		</script>
	</body>
</html>

npm パッケージで使う - Using as a npm package

const sidebarFix = require('@tomk79/sidebar-fix');

// .sidebar-fix を固定します
sidebarFix('.sidebar-fix', {
	frame: $('.sidebar-fix-container'),
	topBuffer: 100,
	force: true
});

既知の問題 - Known problem

  • サイドバーを固定するために、 position: fixed が設定されます。サイドバーが position: fixed のときの包含ブロックにネストされている場合、固定位置がズレることがあります。\
    • force オプションを true にすることで解決できる場合があります。
    • 包含ブロックについては こちら を参照してください。

変更履歴 - Change log

sidebarFix.js v1.2.0 (2021-03-24)

  • スタンドアローン版(jQuery内蔵)を追加。
  • npm でインストールできるようになった。

jquery.sidebarFix.js v1.1.1 (2021-03-22)

  • サイドバーの幅が狭くされることがある問題を修正。
  • オプション force を追加。
  • Firefox で、サイドバーが追従しない場合がある不具合を修正。

jquery.sidebarFix.js v1.1.0 (2016-12-06)

  • オプション topBuffer を追加。

jquery.sidebarFix.js v1.0.2 (2013-07-18)

  • サイドバーを固定しないパターンの時に、overflow を visible に戻すようにした。

jquery.sidebarFix.js v1.0.1 (2013-07-11)

  • サイドバーが static の状態(=もとの位置にある状態)のときに、途中までスクロールダウンしてから少し上に戻ると、位置がずれる不具合を修正。

jquery.sidebarFix.js v1.0.0 (2013-07-11)

  • initial release.

ライセンス - License

MIT License

作者 - Author