HTML
CSS
JavaScript
HTML
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Headroom - 通过 JavaScript 调用</title>
  <link rel="stylesheet" href="https://cdn.w3cbus.com/library/mdui/1.0.2/css/mdui.min.css"/>
</head>
<body style="padding-top: 120px;">

  <div id="banner"></div>

  <div id="tool">
    <button id="pin" class="mdui-btn mdui-color-pink-accent mdui-m-r-1">pin</button>
    <button id="unpin" class="mdui-btn mdui-color-pink-accent mdui-m-r-1">unpin</button>
    <button id="enable" class="mdui-btn mdui-color-pink-accent mdui-m-r-1">enable</button>
    <button id="disable" class="mdui-btn mdui-color-pink-accent">disable</button>
  </div>

  <div class="mdui-container">
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
    <p>test</p>
  </div>

  <script src="https://cdn.w3cbus.com/library/mdui/1.0.2/js/mdui.min.js"></script>
</body>
</html>
CSS
#banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #607D8B;
}

#tool {
  position: fixed;
  top: 80px;
  left: 20px;
}
JavaScript
var $ = mdui.$;
var inst = new mdui.Headroom('#banner');

// method
$('#pin').on('click', function () {
  inst.pin();
});

$('#unpin').on('click', function () {
  inst.unpin();
});

$('#enable').on('click', function () {
  inst.enable();
});

$('#disable').on('click', function () {
  inst.disable();
});

// event
$('#banner').on('pin.mdui.headroom', function () {
  console.log('pin');
});

$('#banner').on('pinned.mdui.headroom', function () {
  console.log('pinned');
});

$('#banner').on('unpin.mdui.headroom', function () {
  console.log('unpin');
});

$('#banner').on('unpinned.mdui.headroom', function () {
  console.log('unpinned');
});