Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body>
    <div id="superWrapper">
        <div id="langSwitch">
            <label><input id="langJa" type="radio" name="lang" value="ja" checked="checked"> 日本語</label>
            <label><input id="langEn" type="radio" name="lang" value="en"> English</label>
        </div>

        <div id="demo">
            <img id="mask" src="http://flat.press/entry/smart-select/mask.png" alt="" width="2000" height="2000">

            <div id="knooo">
                <div id="knooo-glow" class="glow">
                    <img src="http://flat.press/entry/smart-select/knooo_glow.png" alt="" width="109" height="139">
                </div>

                <div id="knooo-hat" class="element">
                    <img src="http://flat.press/entry/smart-select/hat.png" alt="" width="66" height="45">
                </div>

                <div id="knooo-face" class="element">
                    <div id="knooo-face-glow" class="glow">
                        <img src="http://flat.press/entry/smart-select/face_glow.png" alt="" width="100" height="66">
                    </div>
                    <div id="knooo-face-face" class="faceElement">
                        <img src="http://flat.press/entry/smart-select/face_face.png" alt="" width="82" height="66">
                    </div>
                    <div id="knooo-eye-l" class="faceElement">
                        <img src="http://flat.press/entry/smart-select/face_eye_l.png" alt="" width="22" height="22">
                    </div>
                    <div id="knooo-eye-r" class="faceElement">
                        <img src="http://flat.press/entry/smart-select/face_eye_r.png" alt="" width="22" height="22">
                    </div>
                    <div id="knooo-mouse" class="faceElement">
                        <img src="http://flat.press/entry/smart-select/face_mouse.png" alt="" width="100" height="36">
                    </div>
                </div>

                <div id="knooo-body" class="element">
                    <img src="http://flat.press/entry/smart-select/body.png" alt="" width="107" height="77">
                </div>
                <div id="knooo-hand-l" class="element">
                    <img src="http://flat.press/entry/smart-select/hand_l.png" alt="" width="27" height="31">
                </div>
                <div id="knooo-hand-r" class="element">
                    <img src="http://flat.press/entry/smart-select/hand_r.png" alt="" width="27" height="31">
                </div>
                <div id="knooo-legs" class="element">
                    <img src="http://flat.press/entry/smart-select/legs.png" alt="" width="80" height="41">
                </div>
            </div>

            <div id="message">
                <div id="messageBody"></div>
            </div>

        </div>
    </div>
</body>
              
            
!

CSS

              
                @import "compass/css3";

body {
    background: #e7c163;
		overflow: hidden;
}
#superWrapper {
    position: relative;
    max-width: 640px;
		width: 100%;
    margin: 0 auto;
    padding: 20px 0;
		object-fit: contain;
}
#langSwitch {
    margin: 0 20px 20px 20px;
		label {
			display: inline-table;
			margin-right: 20px;
		}
}
#demo {
    position: relative;

    width: 640px;
    height: 640px;

    background: #e7c163;
}
#mask {
    position: absolute;
    top: -630px;
    left: -680px;

    opacity: 0;
}
#message {
    position: absolute;
    top: 0;
    left: 0;

		box-sizing: border-box;
    width: 100%;
		padding: 20px;

    text-align: center;
}
#messageBody {
    display: inline-block;

    margin: 0 auto;
    padding: 15px 20px;

    border-radius: 5px;
    border-radius: 5px;
    background: rgba(0,0,0,.65);
}
#messageBody:after {
    position: absolute;
    bottom: 5px;
    left: 305px;

    content: '';

    border-top: 15px solid rgba(0,0,0,.65);
    border-right: 15px solid transparent;
    border-left: 15px solid transparent;
}
#messageBody p {
    font-family: HelveticaNeue, Helvetica, '游ゴシック', '游ゴシック体', 'Yu Gothic', YuGothic, 'ヒラギノ角ゴ ProN W3', 'Hiragino Kaku Gothic ProN', 'メイリオ', Meiryo, 'MS Pゴシック', 'MS P Gothic', sans-serif;
    font-size: 15px;
		line-height: 140%;

    max-width: 600px;
    margin-bottom: 0;

    text-align: left;
    text-indent: 0;

    color: #ddd;
}
body.en #messageBody p.ja {
    display: none;
}
body.ja #messageBody p.en {
    display: none;
}
p {
	margin: 0;
}
#messageBody p strong {
    font-weight: bold;

    color: #fff;
}
#messageBody p.right {
    text-align: right;
}
#knooo {
    position: absolute;
    top: 300px;
    left: 266px;

    width: 109px;
    height: 139px;
}
#knooo-glow {
    position: absolute;
    z-index: 0;
    top: 0;
    left: 0;
}
#knooo-hat {
    position: absolute;
    z-index: 0;
    top: 0;
    left: 21px;
}
#knooo-face {
    position: absolute;
    z-index: 200;
    top: 13px;
    left: 4px;

    width: 100px;
    height: 66px;
}
#knooo-face-glow {
    position: absolute;
    z-index: 0;
    top: 0;
    left: 0;
}
#knooo-face-face {
    position: absolute;
    z-index: 0;
    top: 0;
    left: 9px;
}
#knooo-face-face {
    position: absolute;
    z-index: 0;
    top: 0;
    left: 9px;
}
#knooo-eye-l {
    position: absolute;
    z-index: 0;
    top: 25px;
    left: 54px;
}
#knooo-eye-r {
    position: absolute;
    z-index: 0;
    top: 25px;
    left: 25px;
}
#knooo-mouse {
    position: absolute;
    z-index: 0;
    top: 30px;
    left: 0;
}
#knooo-body {
    position: absolute;
    z-index: 100;
    top: 50px;
    left: 1px;
}
#knooo-hand-l {
    position: absolute;
    z-index: 0;
    top: 76px;
    left: 82px;
}
#knooo-hand-r {
    position: absolute;
    z-index: 0;
    top: 76px;
    left: 0;
}
#knooo-legs {
    position: absolute;
    z-index: 0;
    top: 98px;
    left: 14px;
}
.marker {
    position: absolute;
    z-index: 500;

    display: none;

    width: 5px;
    height: 5px;

    background: #e00000;
}
.marker.tr {
    top: 0;
    right: 0;
}
.marker.tl {
    top: 0;
    left: 0;
}
.marker.br {
    right: 0;
    bottom: 0;
}
.marker.bl {
    bottom: 0;
    left: 0;
}
.marker.active {
    display: block !important;

    background: #00a8ff;
}
.continue,
.back {
		display: inline-block;
		padding-top: 0.8em;
    color: #fff !important;
}
.continue span {
    display: inline-block;
		margin-right: 0.5em;

    transform: rotate(90deg);
    animation-name: 'blink';
    animation-duration: 1s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    vertical-align: bottom;

    animation-property: opacity;
    backface-visibility: visible;
}
.back span {
    display: inline-block;
		margin-right: 0.5em;

    transform: rotate(-90deg);
    animation-name: 'blink';
    animation-duration: 1s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    vertical-align: bottom;

    animation-property: opacity;
    backface-visibility: visible;
}
.glow {
    animation-name: 'blink';
    animation-duration: .75s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;

    animation-property: opacity;
    backface-visibility: visible;
}
@keyframes 'blink' {
    0% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

              
            
!

JS

              
                (function () {
    $(function () {

        var sceneNum = 0;

        var $mask      = $('#mask');
        var $knooo     = $('#knooo');
        var $knoooGlow = $('#knooo-glow');
        var $hat       = $('#knooo-hat');
        var $body      = $('#knooo-body');
        var $face      = $('#knooo-face');
        var $faceGlow  = $('#knooo-face-glow');
        var $handL     = $('#knooo-hand-l');
        var $handR     = $('#knooo-hand-r');
        var $legs      = $('#knooo-legs');
        var $faceFace  = $('#knooo-face-face');
        var $faceEyeL  = $('#knooo-eye-l');
        var $faceEyeR  = $('#knooo-eye-r');
        var $faceMouse = $('#knooo-mouse');
        var $MB        = $('#messageBody');

        var marker = '<span class="marker tr"></span><span class="marker tl"></span><span class="marker br"></span><span class="marker bl"></span>';


        var scene = function (_num) {
            switch (_num) {
                case 0:
                    sceneNum = 0;

                    $knoooGlow.show();
                    $faceGlow.hide();

                    $MB.fadeOut()
                        .queue(function (nxt) {
                            $(this).html([
                                    '<p class="en">Hi, I’ll show you the great design concept of the Selection Tool UI. At first <strong>click (tap) and select me</strong>.</p>',
                                    '<p class="ja">こんにちは、いまから新しいセレクトツールのUIコンセプトを紹介します。まずは<strong>僕をクリック(タップ)して選択</strong>してください。</p>'
                                ].join(''))
                                .fadeIn();

                            $knooo
                                .append(marker)
                                .hover(
                                    function () {
                                        $(this).find('span').show();
                                    },
                                    function () {
                                        $(this).find('span').hide();
                                    }
                                )
                                .hammer()
                                .bind('click tap', function () {
                                    $(this).unbind('click tap');

                                    $knoooGlow.hide();

                                    $(this).find('span').addClass('active');

                                    $MB.fadeOut()
                                        .queue(function (nxt) {
                                            $(this).html([
                                                    '<p class="en">OK, I was selected. I am <strong>a group object</strong>. Then, please <strong>double-click (pinch out)</strong> me again.</p>',
                                                    '<p class="ja">オーケー、選択されました。僕は<strong>グループオブジェクト</strong>です。今度は僕を<strong>ダブルクリック(ピンチアウト)</strong>してください。</p>'
                                                ].join(''))
                                                .fadeIn();
                                            nxt();
                                        });


                                    $(this).hammer().bind('dblclick doubletap pinchout', function() {
                                        $(this).unbind('dblclick doubletap pinchout');

                                        scene(1);
                                    });
                                });

                            nxt();
                        });
                break;

                case 1:
                    $knooo.find('.tl').transition({ x: -135, y: -120, duration: 300, easing: 'out'});
                    $knooo.find('.tr').transition({ x: 135,  y: -120, duration: 300, easing: 'out'});
                    $knooo.find('.bl').transition({ x: -135, y: 120,  duration: 300, easing: 'out'});
                    $knooo.find('.br').transition({ x: 135,  y: 120,  duration: 300, easing: 'out'});

                    $mask.css({ transform: 'scale(2)' })
                        .transition({ opacity: 0.3, scale: 1.4, duration: 300, delay: 200, easing: 'out'});

                    $hat.transition({   x: 0,       y: '-=104', duration: 300, easing: 'out'});
                    $face.transition({  x: '+=129', y: '-=52',  duration: 300, easing: 'out'});
                    $body.transition({  x: '+=129', y: '+=57',  duration: 300, easing: 'out'});
                    $handL.transition({ x: '-=41',  y: '+=129', duration: 300, easing: 'out'});
                    $handR.transition({ x: '-=90',  y: '+=53',  duration: 300, easing: 'out'});
                    $legs.transition({  x: '-=130', y: '-=124', duration: 300, easing: 'out',
                        complete: function () {
                            $MB.fadeOut()
                                .queue(function (nxt) {
                                    $(this).html([
                                            '<p class="en">Well done! You saw that I was separated. But this is the <strong>temporary</strong> state and I’m <strong>still a group object</strong>. Click “Next” to continue.</p>',
                                            '<p class="ja">体が分解してしまったけれど大丈夫。<strong>一時的</strong>に離れただけで、僕はまだ<strong>グループオブジェクトのまま</strong>です。この続きを見るには”Next”をクリックしてください。</p>',
                                            '<p class="right"><a class="continue" href="#"><span>▲</span>Next</a>'
                                        ].join(''))
                                        .fadeIn();

                                    $knooo.unbind("mouseenter").unbind("mouseleave");

                                    $MB.find('.continue').click(function () {
                                        $(this).unbind('click');
                                        scene(2);
                                    });

                                    nxt();
                                });
                        }
                    });
                break;

                case 2:
                    $knooo.find('.element')
                        .append(marker)
                        .hover(
                            function () {
                                $(this).find('span').show();
                            },
                            function () {
                                $(this).find('span').hide();
                            }
                        )
                        .hammer()
                        .bind('click tap', function () {
                            $('#knooo > .marker').remove();
                            $knooo.find('.element > span').removeClass('active');
                            $(this).find('span').addClass('active');
                        });

                    $MB.fadeOut()
                        .queue(function (nxt) {
                            $faceGlow.show();

                            $(this).html([
                                    '<p class="en">In this state, you can select one of bodies’ object. You need NOT ungroup me to select the object <strong>in lower layer</strong>. <strong>Let’s select the FACE object</strong>.</p>',
                                    '<p class="ja">この状態で僕の体のオブジェクトを選択することもできます。<strong>下層のオブジェクトを選択するために、わざわざグループオブジェクトを解除する必要はない</strong>よ。次は僕の「<strong>顔</strong>」を選んでみてください。</p>'
                                ].join(''))
                                .fadeIn();

                            $face.hammer().bind('click tap', function () {
                                $knooo.find('.element').unbind();
                                $faceGlow.hide();

                                scene(3);
                            });

                            nxt();
                        });
                break;

                case 3:
                    $MB.fadeOut()
                        .queue(function (nxt) {
                            $(this).html([
                                    '<p class="en">OK. Now you selected my face, and it’s also <strong>a group object</strong>. If you wanted to finish the Smart Selection Tool, <strong>click the margin or pinch in</strong>. OR, if you <strong>double-click (pinch out) my face</strong>...!?</p>',
                                    '<p class="ja">ありがとう、いまあなたは僕の顔を選択してます。僕の顔もまた<strong>グループオブジェクト</strong>だよ。このままスマートセレクトから抜けるには、<strong>空白部分をクリックするかピンチイン</strong>してください。または僕の顔をさらに<strong>ダブルクリック(ピンチアウト)</strong>すると...!?</p>'
                                ].join(''))
                                .fadeIn();

                            $('#demo').hammer().bind('click pinchin', function (event) {
                                $(this).unbind('click pinchin');
                                $knooo.find('.element').unbind();

                                scene(4);
                            });

                            $knooo.find('.element').click(function (event) {
                                event.preventDefault();
                                event.stopPropagation();
                            });

                            $face.hammer().bind('dblclick doubletap pinchout', function (event) {
                                $('#demo').unbind();
                                $knooo.find('.element').unbind();

                                scene(5);
                            });

                            nxt();
                        });
                break;

                case 4:
                    $mask.transition({ opacity: 0, scale: 0.2, duration: 300, delay: 200, easing: 'out'});

                    $hat.transition({   x: 0,       y: '+=104', duration: 300, easing: 'out'});
                    $face.transition({  x: '-=129', y: '+=52',  duration: 300, easing: 'out'});
                    $body.transition({  x: '-=129', y: '-=57',  duration: 300, easing: 'out'});
                    $handL.transition({ x: '+=41',  y: '-=129', duration: 300, easing: 'out'});
                    $handR.transition({ x: '+=90',  y: '-=53',  duration: 300, easing: 'out'});
                    $legs.transition({  x: '+=130', y: '+=124', duration: 300, easing: 'out',
                        complete: function () {
                            $MB.fadeOut()
                                .queue(function (nxt) {
                                    $knoooGlow.hide();

                                    $(this).html([
                                            '<p class="en">Hi, you came back to the first state. <strong>You selected my face object without ungroup me!</strong> If you wanted to try it again, click the ”Back”.</p>',
                                            '<p class="ja">これで最初の状態に戻りました。<strong>グループ化を解かずに僕の顔を選択できました</strong>ね。もう一度試すには“Back”をクリックしてね。</p>',
                                            '<p class="right"><a class="back" href="#"><span>▲</span>Back</a></p>'
                                        ].join(''))
                                        .fadeIn();

                                    $MB.find('.back').click(function () {
                                            $(this).unbind('click');
                                            $knooo.find('.marker').remove();
                                            scene(0);
                                    });

                                    nxt();
                                });
                        }
                    });
                break;

                case 5:
                    $mask.transition({ scale: 0.3, opacity: 0.1, duration: 300, easing: 'out'});
                    $face.transition({ x: 4, y: 37, duration: 300, easing: 'out',
                        complete: function () {
                            $mask.transition({ scale: 1.4, opacity: 0.3, duration: 300, delay: 200, easing: 'out'});

                            $face.find('.tl').transition({ x: -140, y: -157, duration: 300, easing: 'out'});
                            $face.find('.tr').transition({ x: 140,  y: -157, duration: 300, easing: 'out'});
                            $face.find('.bl').transition({ x: -140, y: 157,  duration: 300, easing: 'out'});
                            $face.find('.br').transition({ x: 140,  y: 157,  duration: 300, easing: 'out'});

                            $faceFace.transition({  x: 0,       y: '-=151', duration: 300, easing: 'out'});
                            $faceEyeL.transition({  x: '+=135', y: '-=3',   duration: 300, easing: 'out'});
                            $faceEyeR.transition({  x: '+=14',  y: '+=147', duration: 300, easing: 'out'});
                            $faceMouse.transition({ x: '-=150', y: '-=16',  duration: 300, easing: 'out',
                                complete: function () {
                                    scene(6);
                                }
                            });
                        }
                    });

                    $hat.transition({   opacity: 0, duration: 300, easing: 'out'});
                    $body.transition({  opacity: 0, duration: 300, easing: 'out'});
                    $handL.transition({ opacity: 0, duration: 300, easing: 'out'});
                    $handR.transition({ opacity: 0, duration: 300, easing: 'out'});
                    $legs.transition({  opacity: 0, duration: 300, easing: 'out'});
                break;

                case 6:
                    $MB.fadeOut()
                        .queue(function (nxt) {
                            $(this).html([
                                    '<p class="en">Then, I was separated again but it’s not ungrouped. Let’s select one of them.</p>',
                                    '<p class="ja">さらに僕の顔がばらばらになったね。今回もやはりグループは解除されていません。どれかオブジェクトを選んでください。</p>'
                                ].join(''))
                                .fadeIn();

                            $knooo.find('.faceElement')
                                .append(marker)
                                .hover(
                                    function () {
                                        $(this).find('span').show();
                                    },
                                    function () {
                                        $(this).find('span').hide();
                                    }
                                )
                                .hammer()
                                .bind('click tap', function (event) {
                                    event.preventDefault();
                                    event.stopPropagation();

                                    $('#knooo-face > span').remove();

                                    $knooo.find('.faceElement > span').removeClass('active');
                                    $(this).find('span').addClass('active');

                                    if (sceneNum === 0) {
                                        sceneNum = 7;
                                        scene(7);
                                    }
                                });

                            nxt();
                        });
                break;

                case 7:
                    $MB.fadeOut()
                        .queue(function (nxt) {
                            $(this).html([
                                    '<p class="en">OK! You could select the object again. Then, <strong>click the margin (or pinch in)</strong> to back to the first state.</p>',
                                    '<p class="ja">オーケーです、オブジェクトを選択できました。もとの状態に戻るために<strong>空白部分をクリックするかピンチイン</strong>しましょう。</p>'
                                ].join(''))
                                .fadeIn();

                            $('#demo').hammer().bind('click pinchin', function () {
                                $(this).unbind('click pinchin');
                                $face.find('.faceElement').unbind();
                                $face.unbind();

                                scene(8);
                            });

                            nxt();
                        });
                break;

                case 8:
                    $mask.transition({ opacity: 0, scale: 0.2, duration: 300, delay: 200, easing: 'out'});

                    $faceFace.transition({  x: 0,       y: '+=151', duration: 300, easing: 'out'});
                    $faceEyeL.transition({  x: '-=135', y: '+=3',   duration: 300, easing: 'out'});
                    $faceEyeR.transition({  x: '-=14',  y: '-=147', duration: 300, easing: 'out'});
                    $faceMouse.transition({ x: '+=150', y: '+=16',  duration: 300, easing: 'out',
                        complete: function () {
                            $face.transition({ x: 0, y: '-=37', duration: 300, easing: 'out'});

                            $hat.transition({   opacity: 1, x: 0,       y: '+=104', duration: 300, easing: 'out'});
                            $body.transition({  opacity: 1, x: '-=129', y: '-=57',  duration: 300, easing: 'out'});
                            $handL.transition({ opacity: 1, x: '+=41',  y: '-=129', duration: 300, easing: 'out'});
                            $handR.transition({ opacity: 1, x: '+=90',  y: '-=53',  duration: 300, easing: 'out'});
                            $legs.transition({  opacity: 1, x: '+=130', y: '+=124', duration: 300, easing: 'out',
                                complete: function () {
                                    $MB.fadeOut()
                                        .queue(function (nxt) {
                                            $knoooGlow.hide();

                                            $(this).html([
                                                    '<p class="en">Well come back. <strong>You could select the deeper object located in the group</strong>, without ungrouping any group objects.</p>',
                                                    '<p class="ja">おかえりなさい。僕のグループ化を解かずに、<strong>2階層の下のオブジェクトを選択することができました</strong>。もう一度試すには“Back”をクリックしてね。</p>',
                                                    '<p class="right"><a class="back" href="#"><span>▲</span>Back</a></p>'
                                                ].join(''))
                                                .fadeIn();

                                            $MB.find('.back').click(function () {
                                                    $(this).unbind('click');
                                                    $knooo.find('.marker').remove();
                                                    scene(0);
                                            });

                                            nxt();
                                        });
                                }
                            });
                        }
                    });
                break;
            }
        };

        scene(0);

        $('#langEn').click(function () {
            $('body').addClass('en');
            $('body').removeClass('ja');
        });

        $('#langJa').click(function () {
            $('body').addClass('ja');
            $('body').removeClass('en');
        });

        $('body').addClass('ja');

    });
})();
              
            
!
999px

Console