You don’t put the controls in the while loop, then they will come there every time. So you can use a for loop and the found_posts
variable to loop trough the items before and after the while loop.
Example below.
<div class="gallery autoplay items-3">
<?php
$args = array(
'post_type' => 'referanse'
);
$referanser = new WP_Query( $args );
?>
<?php if( $referanser->have_posts() ) : ?>
<?php for($i=1; $i<=$referanser->found_posts; $i++) : ?>
<div id="item-<?php echo $i; ?>" class="control-operator"></div>
<?php endfor; ?>
<?php while( $referanser->have_posts() ) : $referanser->the_post(); ?>
<figure class="item">
<h1><?php the_title() ?></h1>
</figure>
<?php endwhile; ?>
<div class="controls">
<?php for($i=1; $i<=$referanser->found_posts; $i++) : ?>
<a href="#item-<?php echo $i; ?>" class="control-button">•</a>
<?php endfor; ?>
</div>
<?php else : ?>
Ops, ingen referanser enda...
<?php endif; ?>
</div>